我需要使用tweepy检索转推器ID。
import tweepy
import time,json
APP_KEY=""
APP_SECRET=""
OAUTH_TOKEN=""
OAUTH_TOKEN_SECRET=""
auth = tweepy.OAuthHandler(APP_KEY,APP_SECRET)
auth.set_access_token(OAUTH_TOKEN,OAUTH_TOKEN_SECRET)
api = tweepy.API(auth)
'''for status in api.user_timeline(screen_name='acmigdtuw',include_rts=1,count=200):
print status.id'''
firstTweet = api.user_timeline(screen_name="acmigdtuw")[0]
print firstTweet.text
print firstTweet.id
#results = api.retweets(status.id,cursor=-1,stringify_ids=1)
pl = api.retweets.id(id=firstTweet.id)
print pl[0]['user']['screen_name']
答案 0 :(得分:0)
firstTweet = api.user_timeline(screen_name="acmigdtuw")[0]
# get the original tweet
original_tweet = firstTweet.retweeted_status.id
# iterate over retweets to get user id
for status in api.retweets(original_tweet):
print status.user.id
输出:
839110314012598272
390229046
这些是转发原始推文的用户的ID。
我们可以通过将转发数量与结果进行比较来确认:
print firstTweet.retweeted_status.retweet_count == len(api.retweets(original_tweet))
真