我正在使用Pytrends来提取Google趋势数据,例如:
from pytrends.request import TrendReq
pytrend = TrendReq()
pytrend.build_payload(kw_list=['bitcoin'], cat=0, timeframe=from_date+' '+today_date)
并返回一个错误:
ResponseError: The request failed: Google returned a response with code 429.
我昨天做的,但由于某种原因,它现在不能工作!来自github的源代码也失败了:
pytrends = TrendReq(hl='en-US', tz=360, proxies = {'https': 'https://34.203.233.13:80'})
我该如何解决这个问题呢?非常感谢!
发布于 2018-05-31 11:33:54
这一次花了一段时间,但事实证明,这个库只是需要更新。你可以查看我在这里发布的一些方法,这两种方法都产生了状态429响应:
https://github.com/GeneralMills/pytrends/issues/243
最终,通过在bash提示符下运行以下命令,我能够让它再次工作:
运行:
pip install --upgrade --user git+https://github.com/GeneralMills/pytrends
获取最新版本。
希望这对你也有效。
编辑:
如果你不能从源代码升级,你可能会有一些运气:
pip install pytrends --upgrade
此外,如果是在Windows上,请确保您是以管理员身份运行git。
发布于 2018-06-07 04:40:05
通过pip install运行升级命令后,您应该重新启动python内核并重新加载pytrend库。
发布于 2020-06-11 19:56:25
即使在使用pip install --upgrade --user git+https://github.com/GeneralMills/pytrends
更新模块并重新启动python之后,我也遇到了同样的问题。
但是,通过以下方法解决了这个问题:
而不是
pytrends = TrendReq(hl='en-US', tz=360, timeout=(10,25), proxies=['https://34.203.233.13:80',], retries=2, backoff_factor=0.1, requests_args={'verify':False})
只是跑了一下:
pytrend = TrendReq()
希望这能对大家有所帮助!
https://stackoverflow.com/questions/50571317
复制相似问题