2024-04-23 11:22:53 发布
网友
使用Python,我试图从googletrends中获取“主题”的数据(而不是“搜索词”)。你知道吗
我目前正在使用pytrends模块,但似乎(目前)不可能刮取主题而不是搜索词,除非您知道topic_id。你知道吗
pytrends
topic_id
例如,如果您想为topic_name“假日”刮取数据,您可以使用topic_id/m/03gkl搜索,但前提是您知道那是topic_id。你知道吗
topic_name
/m/03gkl
我有一个主题名列表。我想要一个相应的主题ID列表。我怎样才能做到这一点?你知道吗
看起来我没有正确阅读pytrends文档,可以获取主题id:
from pytrends.request import TrendReq pytrends = TrendReq(hl='en-US', tz=360) suggs = pytrends.suggestions("iron") print(suggs) [{'mid': '/m/025rw19', 'title': 'Iron', 'type': 'Chemical element'}, {'mid': '/m/04jphh9', 'title': 'Clothes iron', 'type': 'Topic'}, {'mid': '/m/0b6l369', 'title': 'Loha', 'type': '1987 film'}, {'mid': '/m/03cld36', 'title': 'Iron', 'type': 'Golf'}, {'mid': '/m/0281ql7', 'title': 'Ferric', 'type': 'III'}]
从上面可以很容易地提取主题id
看起来我没有正确阅读
pytrends
文档,可以获取主题id:从上面可以很容易地提取主题id
相关问题 更多 >
编程相关推荐