我想要得到最新的谷歌趋势与热趋势。我已经安装了一个全新的系统,包含Python3.10.1和Py趋势。代码非常简单:
#pip install pytrends
from pytrends.request import TrendReq
pytrends = TrendReq.trending_searches(pn='US')
print(pytrends.head(20))但是,我仍然收到以下错误消息:
TypeError: TrendReq.trending_searches() missing 1 required positional argument: 'self'我在谷歌上找不到任何帮助。你们谁知道这里出了什么问题?
发布于 2021-12-08 21:13:54
我已经为自己找到了解决办法。以下是“勾当趋势”github页面上的例子:
from pytrends.request import TrendReq
pytrend = TrendReq()
trending_searches_df = pytrend.trending_searches(pn = "united_states")
print(trending_searches_df.head())我无法解释为什么互联网上这么多的教程有错误的代码。但是有了这个,它就没有问题了。
https://stackoverflow.com/questions/70277962
复制相似问题