^
|
| this question DOES NOT HAVE an answer yet!
我正在尝试从python脚本进行谷歌搜索。
xing = "site:xing.com inurl:profile intext:Systemadministrator AND UNIX AND Hamburg"
query = urllib.urlencode ( { 'q' : xing } )
response = urllib.urlopen ( 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&' + query ).read()
import json as m_json
json = m_json.loads ( response )
results = json [ 'responseData' ] [ 'results' ]
print len(results)
问题是,它只给了我4个结果。如果我在谷歌中粘贴搜索字符串,它会找到超过100个结果。我在这做错了什么?
编辑
我将代码更改为:
import urllib
import django.utils import simplejson
num_queries = 50*4
xing = "site:xing.com inurl:profile intext:Systemadministrator AND UNIX AND Hamburg"
query = urllib.urlencode({'q' : xing})
url = 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&%s' % query
for start in range(0, num_queries, 4):
request_url = '{0}&start={1}'.format(url, start)
search_results = urllib.urlopen(request_url)
json = simplejson.loads(search_results.read())
results = json['responseData']['results']
return HttpResponse(search_results)
我没有收到任何数据。 search_results
是空的。这是为什么?