예제 #1
0
        public static void search(string search_terms, string channel, string nick, IrcClient irc)
        {
            GwebSearchClient   client  = new GwebSearchClient("");
            IList <IWebResult> results = client.Search(search_terms, 2);

            foreach (IWebResult result in results)
            {
                irc.SendMessage(SendType.Message, channel, string.Format("{0}: {1} => {2}", nick, result.Title, result.Url), Priority.High);
            }
        }
예제 #2
0
        /// <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);
        }
    public void FindEven()
    {
        List <tbl_search> _evenSearchList = db.tbl_search.Where(c => (c.id % 2) == 0).ToList();
        var client = new GwebSearchClient("http://www.google.com");

        foreach (var item in _evenSearchList)
        {
            var        results           = client.Search(item.title, 1);
            tbl_search _saveSearchResult = _evenSearchList.First(x => x.id == item.id);
            _saveSearchResult.result = results.First().ToString();
            lock (dbLock)
            {
                db.SaveChanges();
            }
        }
    }
        /// <summary>
        /// Obtiene una colección de resultados Web de acuerdo a una consulta dada, (API utilizada: Google API Web Search 2.0)
        /// </summary>
        /// <param name="keywords">Palabras clave de la consulta de usuario</param>
        /// <param name="numResults">Numero de resultados que se van a obtener</param>
        /// <returns></returns>
        public System.Collections.ArrayList webSearchGoogle(string keywords, int numResults)
        {
            System.Collections.ArrayList results = new System.Collections.ArrayList();
            //Crear un cliente Google
            GwebSearchClient client = new GwebSearchClient("http://www.google.com.co");

            //Obtener lista de resultados
            System.Collections.Generic.IList <IWebResult> resultsGoogle = client.Search(keywords, numResults);
            foreach (IWebResult result in resultsGoogle)
            {
                WebDocument wd = new WebDocument();
                wd.Titulo  = result.Title;
                wd.Resumen = result.Content;
                wd.Url     = result.Url;
                results.Add(wd);
            }
            return(results);
        }
예제 #5
0
        static void web(string query, SpeechSynthesizer so, SpeechRecognitionEngine si, string[] text)
        {
            GwebSearchClient  client = new GwebSearchClient("http://seb.appspot.com/");
            List <IWebResult> result = new List <IWebResult>(client.Search(query, 50));

            so.Speak(string.Format(text[15], result.Count));
            byte pn = 0, rn = 0;

            while (true)
            {
                so.Speak(text[16] + (pn + 1));
                for (byte i = 0; i < 10; ++i)
                {
                    so.Speak(string.Format(text[17], i + 1, result[pn * 10 + i].Title, new Uri(result[pn * 10 + i].Url).Authority));
                }
pi:
                List <string> s = new List <string>(si.Recognize().Text.ToLower().Replace("one", "1").Replace("two", "2").Replace("three", "3").Replace("four", "4").Replace("five", "5").Replace("six", "6").Replace("seven", "7").Replace("eight", "8").Replace("nine", "9").Replace("ten", "10").Split(text[3].ToCharArray()));
#if DEBUG
                foreach (string x in s)
                {
                    Console.WriteLine(x);
                }
#endif
                s.RemoveAll((string x) => x == "");
                if (s.Contains(text[18]))
                {
                    if (pn < (byte)Math.Ceiling(result.Count / 10.0))
                    {
                        ++pn;
                    }
                }
                else if (s.Contains(text[19]))
                {
                    if (pn > 0)
                    {
                        --pn;
                    }
                }
                else if (s.Contains(text[6]))
                {
                    break;
                }
                else if (s.Contains(text[20]))
                {
                    try
                    {
                        if (!byte.TryParse(s[s.IndexOf(text[20]) + 1], out rn) | rn > 10 | rn < 1)
                        {
                            so.Speak(text[21]);
                            goto pi;
                        }
                        --rn;
                    }
                    catch
                    {
                        so.Speak(text[12]);
                        goto pi;
                    }
                    while (true)
                    {
                        so.Speak(text[22] + (rn + 1));
                        List <string> _ = new List <string>(si.Recognize().Text.ToLower().Split(text[3].ToCharArray()));
                        _.RemoveAll((string x) => x == "");
                        if (_.Contains(text[23]))
                        {
                            so.Speak(text[24]);
                            Process.Start(result[pn * 10 + rn].Url);
                            break;
                        }
                        else if (_.Contains(text[25]))
                        {
                            so.Speak(result[pn * 10 + rn].Content);
                        }
                        else if (_.Contains(text[6]))
                        {
                            break;
                        }
                    }
                }
                else
                {
                    so.Speak("Sorry, didn't get that.");
                    goto pi;
                }
            }
        }