^
|
| 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
是空的。为什么是这样?