Пример #1
0
        /// <summary>
        /// Ищет ссылки, по которым будет осуществляться поиск текста
        /// </summary>
        /// <param name="queries">Лист с вопросами</param>
        public void RunSearchLinks(List<string> queries)
        {
            for (int i = 0; i < queries.Count; i++)
            {
                if (queries[i] == "") continue;
                WebQuery query = new WebQuery(queries[i].Replace(".", "").Replace(",",""));
                query.StartIndex.Value = 1;
                query.HostLangauge.Value = "Russian";
                List<string> urls = new List<string>();

                IGoogleResultSet<GoogleWebResult> resultSet = GoogleService.Instance.Search<GoogleWebResult>(query);
                for (int j = 0; j < resultSet.Results.Count; j++)
                {
                    tableNumQuery.Rows.Add(new object[] { i + 1, resultSet.Results[j].Url });
                }
                System.Threading.Thread.Sleep(500);
            }
        }
Пример #2
0
        public static void Google(string msg, bool state)
        {
            // Get the googleing
            string google = Utils.Remove(msg, state ? "google" : "g", true);

            // Google
            WebQuery query = new WebQuery(google);
            query.HostLangauge.Value = Languages.English;
            query.CountryCode.Value = CountryCode.United_States;
            IGoogleResultSet<GoogleWebResult> result = null;

            try
            {
                result = GoogleService.Instance.Search<GoogleWebResult>(query);

                // Return a link
                GoogleWebResult web = result.Results.First();
                SendMessage(message.User.Nick + ": " + web.Url + " [" + web.TitleNoFormatting + "]");
            }
            catch
            {
                SendMessage(message.User.Nick + ": I couldn't find anything related to your search on Google.");
            }
        }
Пример #3
0
 private void btnGoogleSearch_Click(object sender, EventArgs e)
 {
     WebQuery query = new WebQuery(tbQuery.Text);
     IGoogleResultSet<GoogleWebResult> resultSet = GoogleService.Instance.Search<GoogleWebResult>(query);
     dgvResults.DataSource = resultSet.Results;
 }