Twitter Streaming:根据国家/地区获取 Twitter 上的趋势

Twitter Streaming: Get trends on Twitter on the basis of countries

我正在使用 tweepy 获取 Twitter 推文。我想根据我选择的国家/地区了解当前趋势。我的代码如下:

import tweepy
file = open("data.txt", 'r')
authentication = tweepy.OAuthHandler('consumer_key', 'consumer_secret')
authentication.set_access_token('access_token', 'access_secret')
api = tweepy.API(authentication)
trends = api.trends_available()
for trend in trends:
    print trend

上面的代码给了我一个国家列表。我想用这个列表来查看当前国家的趋势。如何提取这些国家/地区的趋势 hashtags

我遇到了 this 个问题,但没有答案。

您为此工作使用了错误的端点,您必须使用 this 转换为 tweepy api.trends_place(woeid) 并提供本页中所述的 woeid,您还可以获得来自 api.trends_available() 个结果。