コード例 #1
0
 public void GetRawDataG()
 {
     for (int i = 0; i < humanlist.Count; i++)
     {
         double rate = 0;
         long begin = DateTime.Now.Ticks;
         GQueryService service = new GQueryService(humanlist[i].name + " " + humanlist[i].city1);
         List<GQueryResult> result = service.GetResult();
         //
         if (result.Count != 0) Console.WriteLine("Status OK in Google results");
         //
         foreach (var item in result)
         {
             if (GetResponse(item.Url, Encoding.UTF8))
             {
                 humans.Add(humanlist[i], geturls(htmlpage));
                 SmartAnalyse(false);
                 rate = SmartGoogleAnalyse();
             }
         }
         TimeSpan span = new TimeSpan(DateTime.Now.Ticks - begin);
         if (span.TotalSeconds < 5) Thread.Sleep((5 - (int)span.TotalSeconds)*1000);
     }
 }
コード例 #2
0
 public void GetRawDataG()
 {
     mre.WaitOne();
     for (int i = 0; i < manlist.Count; i++)
     {
         string query;
         if (manlist[i] != null)
         {
             for (int j = 2; j >= 2; j--)
             {
                 long begin = DateTime.Now.Ticks;
                 query = SmartQueryToGoogle(i, j);
                 if (query != null && query != "")
                 {
                     GQueryService service = new GQueryService(query);
                     List<GQueryResult> result = service.GetResult();
                     if (result != null && result.Count > 0)
                     {
                         foreach (var item in result)
                         {
                             if (j == 0 || j == 1)
                             {
                                 if (item.Title.Contains(manlist[i].nicks[j].ToString()) || ( item.Content != null && item.Content.Contains(manlist[i].nicks[j].ToString())))
                                 {
                                     if (item.Url.Contains("http"))
                                     manlist[i].find(item.Url);
                                 }
                             }
                             else if (j == 2)
                             {
                                 if (item.Title.Contains(manlist[i].name) || item.Title.Contains(manlist[i].eman(manlist[i].name))
                                     || item.Content.Contains(manlist[i].name) || item.Content.Contains(manlist[i].eman(manlist[i].name)))
                                 {
                                     if (item.Url.Contains("http"))
                                     manlist[i].find(item.Url);
                                 }
                             }
                         }
                     }
                 }
                 if (manlist[i].links.Count >= 5) break;
                 TimeSpan span = new TimeSpan(DateTime.Now.Ticks - begin);
                 if (span.TotalSeconds < 4)
                 {
                     int duration = 4 - (int)span.TotalSeconds;
                     Thread.Sleep(duration * 1000);
                 }
             }
         }
     }
 }
コード例 #3
0
 public void GetRawDataSoc()
 {
     VQueryService vservice;
     if (fake.Age != null)
     {
         vservice = new VQueryService(fake.Name, (short)fake.Age, "belarus");
     }
     else
     {
         vservice = new VQueryService(fake.Name, 0, "belarus");
     }
     List<VQueryResult> r = null;
     if (opcode != 1 && opcode != 2) r = vservice.GetResult();
     if (r != null && r.Count > 0)
     {
         int i = 0;
         Thread.Sleep(2000);
         foreach (var item in r)
         {
             long begin = 0;
             Man man = new Man();
             begin = DateTime.Now.Ticks;
             //блокировка до поступления нового человека
             mre.Reset();
             htmlpagevk = man.vk_parsing(item.Url);
             lock (_lock)
             {
                 manlist.Add(man);
             }
             SmartAnalyse(true, i);
             i++;
             //разрешение на обработку данных другим потоком
             mre.Set();
             TimeSpan span = new TimeSpan(DateTime.Now.Ticks - begin);
             if (span.TotalSeconds < 4)
             {
                 int duration = 4 - (int)span.TotalSeconds; 
                 Thread.Sleep(duration * 1000);
             }
         }
     }
     else
     {
         GQueryService gservice;
         List<GQueryResult> g = null;
         if (fake.Location != null)
         {
             gservice = new GQueryService(fake.Name + " " + fake.Location, "my.mail.ru");
         }
         else if (fake.Age != null)
         {
             gservice = new GQueryService(fake.Name + " " + fake.Age, "my.mail.ru");
         }
         else gservice = new GQueryService(fake.Name, "my.mail.ru");
         if (opcode != 2) g = gservice.GetResult();
         if (g != null && g.Count > 0)
         {
             int i = 0;
             foreach (var item in g)
             {
                 if (item.Title.ToLower().Contains(fake.Name.ToLower()))
                 {
                     long begin = 0;
                     Man man = new Man();
                     begin = DateTime.Now.Ticks;
                     //блокировка до поступления нового человека
                     mre.Reset();
                     htmlpagevk = man.mm_parsing(item.Url);
                     lock (_lock)
                     {
                         manlist.Add(man);
                     }
                     SmartAnalyse(false, i);
                     i++;
                     //сигнал о разрешении обработки данных
                     //другим потоком
                     mre.Set();
                     TimeSpan span = new TimeSpan(DateTime.Now.Ticks - begin);
                     if (span.TotalSeconds < 4)
                     {
                         int duration = 4 - (int)span.TotalSeconds;
                         Thread.Sleep(duration * 1000);
                     }
                 }
             }
         }
         else
         {
             if (fake.Location != null)
             {
                 g = new GQueryService(fake.Name + " " + fake.Location, "odnoklassniki.ru").GetResult();
             }
             else if (fake.Age != null)
             {
                 g = new GQueryService(fake.Name + " " + fake.Age, "odnoklassniki.ru").GetResult();
             }
             else g = new GQueryService(fake.Name, "odnoklassniki.ru").GetResult();
             if (g != null && g.Count > 0)
             {
                 int i = 0;
                 foreach (var item in g)
                 {
                     if (item.Title.ToLower().Contains(fake.Name.ToLower()))
                     {
                         long begin = 0;
                         Man man = new Man();
                         begin = DateTime.Now.Ticks;
                         //блокировка до поступления нового человека
                         mre.Reset();
                         htmlpagevk = man.od_parsing(item.Url);
                         lock (_lock)
                         {
                             manlist.Add(man);
                         }
                         SmartAnalyse(false, i);
                         i++;
                         //сигнал о разрешении обработки данных
                         //другим потоком
                         mre.Set();
                         TimeSpan span = new TimeSpan(DateTime.Now.Ticks - begin);
                         if (span.TotalSeconds < 4)
                         {
                             int duration = 4 - (int)span.TotalSeconds;
                             Thread.Sleep(duration * 1000);
                         }
                     }
                 }
             }
         }
     }
     mre.Set();
     //проанализировать на ключевые элементы
     //SmartAnalyse(true, i);
 }