我希望以尽可能最快的方式仅返回特定关键字的谷歌搜索结果的数量,以避免(至少保留)使用第三方库。我已经考虑过xgoogle。仅通过Python返回Google搜索结果的数量
回答
如果您搜索“汽车”之类的模糊内容,data
将如下所示。注意它不是很长;您只能获得排名前几位的点击数,并可链接到“moreResultsUrl”。因此,进行此查询的速度应该相当快,并在 data['cursor']['estimatedResultCount']
中查看估计的点击次数。
{'cursor': {'currentPageIndex': 0,
'estimatedResultCount': '168000000',
'moreResultsUrl': 'http://www.google.com/search?oe=utf8&ie=utf8&source=uds&start=0&hl=en&q=cars',
'pages': [{'label': 1, 'start': '0'},
{'label': 2, 'start': '4'},
{'label': 3, 'start': '8'},
{'label': 4, 'start': '12'},
{'label': 5, 'start': '16'},
{'label': 6, 'start': '20'},
{'label': 7, 'start': '24'},
{'label': 8, 'start': '28'}]},
'results': [ <<list of 4 dicts>> ]}
您可以使用urllib下载网站,HTMLParser解析出 <div id="resultStats">....</div>
值。这里有一个例子:
How can I use the python HTMLParser library to extract data from a specific div tag?
值得一提的是,当使用urllib时,你将不得不欺骗浏览器代理ID - 并且Google在自动查询时皱眉了... – 2010-07-26 12:27:37
谢谢,这个答案也帮助我解决了其他困难。 – subiet 2010-07-28 04:10:24
- 1. Google Maps API本地搜索仅返回4个结果?
- 2. 为什么Google App Engine搜索仅返回“最佳”结果?
- 3. Excel的Google搜索结果数量
- 4. DataTable - 返回搜索结果
- 5. 如何通过python包查找Google搜索结果
- 6. 返回Google Search Appliance搜索结果中的元数据字段
- 7. 如何限制本C#程序中返回的Google搜索结果的数量?
- 8. 如何让Google地图搜索仅返回当前可见区域的结果?
- 9. Postgresql:返回搜索结果不在搜索结果
- 10. 通过JQuery Ajax和经典ASP返回搜索结果
- 11. Android GeoCoder:通过邮政编码搜索返回意外结果
- 12. 如何通过Wikipedia API返回多个搜索结果?
- 13. 通过地图列表搜索并返回多个结果
- 14. Google Custom Search仅返回“无结果”
- 15. Google自定义搜索仅限Python购物结果?
- 16. Python。从Google搜索结果中仅获取href链接内容
- 17. Google Ajax搜索结果与“普通”Google搜索结果有什么不同?
- 18. Google Maps API Places搜索获取搜索结果数量
- 19. SearchListItems返回0结果,但SharePoint搜索返回5页结果
- 20. 限制弹性搜索返回结果的数量
- 21. Sharepoint网络服务搜索:返回的结果数量指定
- 22. 通过日志文件Python自定义搜索不返回结果
- 23. Lucene搜索返回不同的结果
- 24. 0从NetSuite搜索返回的结果
- 25. Twitter的JSON搜索结果返回空
- 26. 雷达搜索Google Places API返回的结果太少
- 27. Google搜索返回页面上的结果 - HTML
- 28. Facebook图形API,仅返回经过验证的帐户的搜索结果
- 29. 数据库搜索只返回1搜索结果
- 30. 过滤Google网站搜索结果
你的问题是什么?你的代码在哪里? – SilentGhost 2010-07-26 10:56:36