请耐心等待,因为我仍在学习 Python..
我希望能够看到特定主题标签的 HitTest 门推文。我可以找到热门推文,也可以找到带有特定主题标签的推文,但在尝试将这两者结合起来时,我不知所措。
import tweepy
CONSUMER_KEY = 'key'
CONSUMER_SECRET = 'secret'
OAUTH_TOKEN = 'key'
OAUTH_TOKEN_SECRET = 'secret'
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
api = tweepy.API(auth)
trends = api.trends_place(1)
search_hashtag = tweepy.Cursor(api.search, q='hashtag').items(5000)
for tweet in search_hashtag:
print json.dumps(tweet)
print json.dumps(trends, indent=1)
这就是我现在所拥有的正在运行的..
谢谢!
最佳答案
发件人:https://dev.twitter.com/rest/public/search
It allows queries against the indices of recent or popular Tweets and behaves similarly to, but not exactly like the Search feature available in Twitter mobile or web clients, such as Twitter.com search. The Twitter Search API searches against a sampling of recent Tweets published in the past 7 days.
因此,您几乎已经得到了想要的东西。这些实际上是特定主题标签/主题的热门推文。
https://dev.twitter.com/rest/reference/get/trends/place只是为了获取特定位置的热门话题,但从您的问题来看,您似乎想按某个特定主题进行搜索,而不是当前 tr 的主题
关于python - 使用 Tweepy 查找特定关键字的热门推文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42559155/