所以我在最后一个问题上被低估了 3 次,我希望我不会在这个问题上。我正在尝试编写一个解析 Google 页面的解析器,如下所示:urllib2.urlopen("http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=" + infoget).
这是允许的吗?我似乎无法根据谷歌找到规则。每天/小时允许多少请求?我赚了大约40,然后我被拒绝了。
这是黑帽子吗?我真的,绝对不是想在这里成为黑帽——我正在尝试编写可接受的、好的代码。
https://developers.google.com/custom-search/v1/overview?hl=en
Free quota
Usage is free for all users, up to 100 queries per day.
我们有一个 Python 库来获取和解析 Google 搜索结果,可在此处访问:https ://github.com/serpapi/google-search-results-python
from lib.google_search_results import GoogleSearchResults
query = GoogleSearchResults({"q": "coffee"})
html_results = query.get_html()
它目前仅适用于 SerpApi.com 后端,但可以随意扩展它以支持更多后端。
更全面的选择:
query_params = {
"q": "query",
"google_domain": "Google Domain",
"location": "Location Requested",
"device": device,
"hl": "Google UI Language",
"gl": "Google Country",
"safe": "Safe Search Flag",
"num": "Number of Results",
"start": "Pagination Offset",
"serp_api_key": "Your SERP API Key"
}
query = GoogleSearchResults(query_params)
query.params_dict["location"] = "Portland"
html_results = query.get_html()
dictionary_results = query.get_dictionary()
dictionary_results_with_images = query.get_dictionary_with_images()
json_results = query.get_json()
json_results_with_images = query.get_json_with_images()