private static IList<string> SearchWithGoogleAPI(string query)
        {
            var gclient = new GwebSearchClient("mysite");
            var searchResult = gclient.Search(query, 1000);

            if (searchResult != null)
            {
                return searchResult.Select(result => result.Url).ToList();
            }

            return null;
        }
Exemple #2
0
        public string Search(string query)
        {
            GwebSearchClient gweb = new GwebSearchClient("http://ubound.hipchat.com");

            var results = gweb.Search(query, 1);

            try
            {
                if (results.Count > 0)
                {
                    foreach (var result in results)
                    {
                        return result.Url;
                    }
                }
            }
            catch
            {
                return "Error in search!";
            }

            return "Whoa! Error in program logic... exiting gracefully";
        }
 public IList<IWebResult> getWebQueryResults(String query)
 {
     GwebSearchClient client = new GwebSearchClient("http://hopepointe.org");
        IList<IWebResult> results = client.Search(query, 32);
        return results;
 }
        /// <summary>
        /// Поиск
        /// </summary>
        /// <param name="searchText">Текст для поиска</param>
        /// <param name="mode">Тип поиска</param>
        /// <returns></returns>
        private List<SearchResultModel> Search(string searchText, int mode)
        {
            var resultOut = new List<SearchResultModel> { };
            switch (mode)
            {
                case 1:
                    GnewsSearchClient t = new GnewsSearchClient("");
                    var SearchResult = t.Search(searchText, 10);
                    foreach (var item in SearchResult)
                    {
                        resultOut.Add(new SearchResultModel { ClusterUrl = item.ClusterUrl, Content = item.Content, Num = 0 });
                    }
                    break;
                case 2:
                    GvideoSearchClient t2 = new GvideoSearchClient("");
                    var SearchResult2 = t2.Search(searchText, 10);
                    foreach (var item in SearchResult2)
                    {
                        resultOut.Add(new SearchResultModel { ClusterUrl = item.PlayUrl, Content = item.Content, Num = 0 });
                    }
                    break;
                case 3:
                    GblogSearchClient t3 = new GblogSearchClient("");
                    var SearchResult3 = t3.Search(searchText, 10);
                    foreach (var item in SearchResult3)
                    {
                        resultOut.Add(new SearchResultModel { ClusterUrl = item.BlogUrl, Content = item.Content, Num = 0 });
                    }
                    break;
                case 4:
                    GwebSearchClient t4 = new GwebSearchClient("");
                    var SearchResult4 = t4.Search(searchText, 10);
                    foreach (var item in SearchResult4)
                    {
                        resultOut.Add(new SearchResultModel { ClusterUrl = item.Url, Content = item.Content, Num = 0 });
                    }
                    break;

            }
            return resultOut;
        }
        static void searchGoogle(string query)
        {
            outputLabelText("   SEARCHING GOOGLE FOR:", query);
            string outputFile = System.IO.Path.GetFullPath(query.Replace(":", "-")) + "\\__googleSearchResults.txt";
            GwebSearchClient client = new GwebSearchClient("www.google.com");
            IList<IWebResult> results = client.Search(query, 10); //max is 64
            outputLabelText("       FOUND:", results.Count.ToString());
            string urls = "";
            int i = 1;
            foreach (IWebResult result in results)
            {
                urls += i + delimiter + result.Title.ToString() + delimiter + result.Url.ToString() + System.Environment.NewLine;

                i++;
            }
            System.IO.File.WriteAllText(outputFile, urls);
            outputLabelText("       URL FILE:", outputFile);
        }
Exemple #6
0
 private Results GoogleSearch(string search)
 {
     try
     {
         List<Control> images = new List<Control>();
         Thread ImageThread = new Thread(() =>
         {
             GimageSearchClient imageSearch = new GimageSearchClient("https://www.images.google.com");
             IList<IImageResult> imageResults = imageSearch.Search(search, 25);
             Parallel.ForEach(imageResults, imr =>
             {
                 try
                 {
                     PictureBox p = new PictureBox();
                     WebClient wc = new WebClient();
                     byte[] im = wc.DownloadData(imr.Url);
                     MemoryStream ms = new MemoryStream(im);
                     p.Image = Image.FromStream(ms);
                     float w = p.Image.PhysicalDimension.Width, h = p.Image.PhysicalDimension.Height;
                     while (w > 250) { w *= .8F; h *= .8F; }
                     p.Width = (int)w;
                     p.Height = (int)h;
                     p.SizeMode = PictureBoxSizeMode.StretchImage;
                     p.Click += delegate(object a, EventArgs b)
                     {
                         Process.Start(imr.Url);
                         this.Contract();
                     };
                     p.Cursor = System.Windows.Forms.Cursors.Hand;
                     images.Add(p);
                 }
                 catch (Exception e) { }
             });
             SearchResultLink link = new SearchResultLink(search, 2);
             images.Add(link);
         });
         ImageThread.Start();
         IList<IWebResult> webResults = null;
         Thread webThread = new Thread(() =>
         {
             GwebSearchClient gs = new GwebSearchClient("https://www.google.com");
             webResults = gs.Search(search, 25, "English", "Off");
         });
         webThread.Start();
         ImageThread.Join();
         webThread.Join();
         return new Results(webResults, images);
     }
     catch (Exception e) { return null; }
 }