简体   繁体   English

使用大型搜索引擎API之一获取搜索结果数量

[英]Get number of search results using one of the big search engine APIs

i am searching for a way to retrieve the number of search results (like on google result pages) for a given query. 我正在寻找一种方法来检索给定查询的搜索结果数(例如在Google结果页上)。 the aim is to implementent the normalized google distance (http://iknowate.blogspot.com/2011/10/google-similarity-distance.html) using a search api; 目的是使用搜索API实施标准化的Google距离(http://iknowate.blogspot.com/2011/10/google-similarity-distance.html); the main problem is that the number of requests shouldnt be too limited (google api seems to allow only ~100 queries / day). 主要问题是请求的数量不应太有限(Google API似乎每天仅允许100次查询)。

maybe someone could give me a hint how i could retrieve this information. 也许有人可以给我一个提示,我该如何检索此信息。

You could either use a third party library/class to scrape the results page and then traverse the DOM to get your info or use file_get_contents to get the page and then use preg_match to get the total number of results. 您可以使用第三方库/类刮取结果页面,然后遍历DOM获取信息,或者使用file_get_contents获取页面,然后使用preg_match获取结果总数。 Another option would be to scrape the page using CURL which would also enable you to hide your script behind multiple Agents to prevent any kind of bans if you intend to scrape pages multiple times. 另一种选择是使用CURL刮取页面,这也使您可以将脚本隐藏在多个Agent后面,以防止如果您打算多次刮取页面的任何形式的禁止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM