search keywords in google through c# window application

前端 未结 2 1338
清酒与你
清酒与你 2020-12-16 08:05

i want to work on a scraper program which will search keyword in google. i have problem in starting my scraper program. my problem is: let suppose window application(c#) hav

2条回答
  •  情歌与酒
    2020-12-16 08:27

    I agree with Paqogomez that you don't appear to have put much work into this but I also understand that it can be hard to get started. Here is some sample code that should get you on the right path.

        private void button1_Click(object sender, EventArgs e)
        {
            string uriString = "http://www.google.com/search";
            string keywordString = "Test Keyword";
    
            WebClient webClient = new WebClient();
    
            NameValueCollection nameValueCollection = new NameValueCollection();
            nameValueCollection.Add("q", keywordString);
    
            webClient.QueryString.Add(nameValueCollection);
            textBox1.Text = webClient.DownloadString(uriString);
        }
    

    This code will search for "Test Keyword" on Google and return the results as a string.

    The problems with what you are asking is Google is going to return your result as HTML that you will need to parse. I really think you need to do some research on the Google API and what is needed to programmatically request data from Google. Start your search here Google Developers.

    Hope this helps get you started on the right path.

提交回复
热议问题