【发布时间】:2020-04-07 07:35:28
【问题描述】:
一段时间后我运行代码时,它给了我代码:429,这意味着已经向该 URL 发出了太多请求,所以过了一会儿,我再次尝试,但我加起来最多 10 秒延迟,仍然给了我代码。 【429】
代码如下:
import requests
import time
query = "programming"
while True:
response = requests.get('https://www.google.com/search?q=' + query)
print (response.status_code)
time.sleep(10) # How much delay should I add?
输出:
.
.
.
200
200
200
429
429
429
429
429
429
.
.
.
我的问题是,我应该添加多少延迟才能使代码全天运行(例如 12 小时),响应代码为 200?
我的方式是否理想?因为我在网上找到了一些关于 Quota and pricing for google 的内容,并想知道这是否与这种情况有关。
【问题讨论】:
标签: python python-3.x python-requests google-search-api