我想从 twitter api 中检索前 10 名或前 20 名最流行的主题标签。
我该怎么做,是否有任何直接的 api,或者我应该使用 twitter 搜索 api 收集大型数据集并手动收集流行的主题标签?
最佳答案
Twitter API 文档是 here .
使用 Tweepy(推荐方法):
import tweepy
consumer_key ="PUT_YOUR_KEY"
consumer_secret ="PUT_YOUR_KEY"
access_token ="PUT_YOUR_KEY"
access_token_secret ="PUT_YOUR_KEY"
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
tags = api.trends_place(23424848) # 23424848 Corresponds to the Yahoo ID for India. Change this to the location that you require.
如果您没有安装 tweepy,请使用:pip install tweepy
关于twitter - 使用 twitter api 获取最流行的主题标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20198600/