在谷歌上执行搜索并在第二页上检索结果

时间:2014-08-16 10:47:13

标签: c# search-engine

我正在使用SharpDevelop平台,我想对谷歌搜索表达式,然后生成第一页中所有网址的列表,第二页上的另一个列表等。使用我发现的一些示例代码,我可以从第一页检索结果。如何修改代码以在第二页上获得结果? 也许有比我发现的更好的方法,例如使用谷歌API?

以下是代码:

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.Net;
using System.Collections.Specialized;

namespace GoogleSearch
{
    /// <summary>
    /// Description of MainForm.
    /// </summary>
    public partial class MainForm : Form
    {
        public MainForm()
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();


            //
            // TODO: Add constructor code after the InitializeComponent() call.
            //
        }

        void Button1Click(object sender, EventArgs e)
        {
            string uriString = "http://www.google.com/search";
            string keywordString = "search expression";

            WebClient webClient = new WebClient();

            NameValueCollection nameValueCollection = new NameValueCollection();
            nameValueCollection.Add("q", keywordString);

            webClient.QueryString.Add(nameValueCollection);
            textBox1.Text = webClient.DownloadString(uriString);            
        }


    }
}

0 个答案:

没有答案