使用tweepy在Python中关注发特定标签推文的用户?
有没有人能给我看看代码,教我怎么关注所有发关于某个特定标签的用户呢?
1 个回答
2
我想你可以使用 twython 这个库,先从一个搜索的 示例 开始,然后根据你的需求进行修改。
from twython import Twython, TwythonError
# Requires Authentication as of Twitter API v1.1
twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
try:
search_results = twitter.search(q='#python', count=50)
except TwythonError as e:
print e
for tweet in search_results['statuses']:
print tweet['user']['screen_name'].encode('utf-8')