C# 如何获取带有查询结果的谷歌页面?
我想从“www.google.com”下载查询结果。我有以下代码:C# 如何获取带有查询结果的谷歌页面?,c#,.net,google-search,C#,.net,Google Search,我想从“www.google.com”下载查询结果。我有以下代码: string query = "where buy a nice dress in Londod"; string site = "www.google.com"; string page = ??; //What I must to do in order to get this page 有什么方法可以满足我的要求吗?基本谷歌查询可以按以下方式格式化: http://www.google.com/#q=day+of+the
string query = "where buy a nice dress in Londod";
string site = "www.google.com";
string page = ??; //What I must to do in order to get this page
有什么方法可以满足我的要求吗?基本谷歌查询可以按以下方式格式化:
http://www.google.com/#q=day+of+the+tentacle
(在q=)之后搜索关键字。您需要创建一个web爬虫程序,如果您使用python,它很简单,如下所示:
import urllib2
url = "http://www.google.com"
request = urllib2.Request(url)
response = urllib2.urlopen(request)
document = response.read()
print document
请注意这里关于下载网页的大量问题。顺便说一句,你不应该这样做。这是对谷歌的TOS,可能会让你被封锁。如果你想以编程方式搜索,它们会公开API。但这是webcrawler所需要的。我刚刚在python o.o+1中展示了一个例子,因为sfelixjr是我们论坛的新用户,如果人们到处打他的电话寻求回复,他可能不会再发表评论。