python通过google api抓取google搜索结果,其中q参数为要搜索的关键词
#!/usr/bin/python import urllib import simplejson query = urllib.urlencode({'q' : '75271.com'}) url = 'http://ajax.useso.com/ajax/services/search/web?v=1.0&%s'%(query) search_results = urllib.urlopen(url) json = simplejson.loads(search_results.read()) print(json) results = json['responseData']['results'] for i in results: print i['title'] + ": " + i['url']