使用C#在Google中搜索 [英] Search in Google in C#

查看:101
本文介绍了使用C#在Google中搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们
我需要一个程序来搜索Google页面并将标题保存在txt文件中

有人可以帮助我吗?

hi guys
i need a program to search in google pages and save titles in a txt file

anyone can help me?

推荐答案

您需要使用HTTP请求方法"GET"(默认设置)使用类System.Net.HttpWebRequest.编译时错误将为System.Net.WebRequest类型,因为运行类型将根据对工厂方法System.Net.WebRequest.Create 参见:
http://msdn.microsoft.com/en-us/library/system.net. httpwebrequest.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system.net. webrequest.aspx [ ^ ](请参见此处的代码示例).

您需要获取响应流并进行处理.它将返回您可以解析并提取所需数据的HTML文件.您还需要学习如何将请求传递给Google.您可以通过与Google进行实验,查看生成的请求URL等来实现.顺便说一下,据我所知,现在不建议使用Google搜索API.

—SA
You need to use the class System.Net.HttpWebRequest using HTTP request method "GET" (which is the default). Compile-time error will be of the type System.Net.WebRequest though as the run-type will be determined based on URL by the call to the factory method System.Net.WebRequest.Create

See:
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx[^],
http://msdn.microsoft.com/en-us/library/system.net.webrequest.aspx[^] (see the code sample here).

You need to get response stream and process it. It will return you the HTML file which you can parse and extract the data you need. You also need to learn how to pass a request to Google. You can do it just by experimenting with Google, looking at generated request URLs, etc. By the way, Google search API is now deprecated, to best of my knowledge.

—SA


这篇关于使用C#在Google中搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆