问题
I am using tweepy
to get twitter tweets. I want to get the current trends based on the country of my choice. My code is as follows:
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
The code above gives me a list of countries. I want to use the list to check the current trends in the country. How do I extract the trending hashtags
for these countries?
I came across this question but it has no answers.
回答1:
you are using the wrong endpoint for this job you have to use this which translates to tweepy api.trends_place(woeid)
and provide an woeid
as described in this page which you can get also from api.trends_available()
results.
来源:https://stackoverflow.com/questions/29755110/twitter-streaming-get-trends-on-twitter-on-the-basis-of-countries