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

匆匆过客 提交于 2019-12-24 13:10:35

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!