我正在用Python编写一个Web抓取工具,该抓取工具使用Google Python module在不同站点中查找关键字列表。运行搜索多次后,我得到了429 HTTPError(too many requests)
。该错误无法指示请求数量的限制是多少,也不能指示在发送另一个请求之前要等待多少时间。我的问题是:有人遇到同样的问题,我该如何处理?
我在try / except语句中捕获了错误,但是不确定继续的条件是什么。
try:
print("search starts")
search_results = list(
search(
self.searched_word,
domains=[self.site],
tbs="qdr:d",
stop=100,
)
)
print("search ends")
except urllib.error.HTTPError as err:
print(err.msg)
print("Waiting to avoid spamming Google search.")
# Not sure if 60 seconds is sufficient
time.sleep(60)
# The 429 (too many requests) error is not handled in the second call
search_results = list(
search(
self.searched_word,
domains=[self.site],
tbs="qdr:d",
stop=100,
)
)
您是否找到了解决方案?我现在正遇到相同的问题:(