Pytrends - API 调用的国家/地区代码问题

问题描述

我希望通过 Pytrends API 获取每个国家/地区的 Google 趋势。

不幸的是,我注意到对于我想下载的许多国家/地区的趋势不起作用,尽管我确信它应该起作用。

示例:

from pytrends.request import TrendReq
pytrend = TrendReq()

count = ['DE','AF','FR']

for country in count:
    try:
        Trends2020_df = pytrend.top_charts(2019,hl='en-US',geo=country)
        Trends2020_df.to_csv(country+'_Trend2020.csv')
        print(country + ' was succesfully pulled from google trends and stored')
    except Exception as e:
        print(country + ' was not successfully pulled because of the following error: ' + str(e))
        continue

对于德国和法国,我得到了数据。不适合阿富汗。

Error

但是当我在 Google Trends 上查看 URL 时,国家/地区代码与我使用的国家/地区代码相对应。

Google Trends URL

这些问题的可能原因是什么?非常感谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)