获取每个tweet-id的所有转发用户id



我有一个推特Id超过100的列表,我想获得每条推特Id的所有转发Id我使用的代码是一条推特Id如何给出推特Id列表并检查是否有推特Id打印用户Id

# import the module 
import tweepy 

# assign the values accordingly 
consumer_key = "" 
consumer_secret = "" 
access_token = "" 
access_token_secret = "" 

# authorization of consumer key and consumer secret 
auth = tweepy.OAuthHandler(consumer_key, consumer_secret) 

# set access to user's access key and access secret  
auth.set_access_token(access_token, access_token_secret) 

# calling the api  
api = tweepy.API(auth) 

# the ID of the tweet 
ID = 1265889240300257280

# getting the retweeters 
retweets_list = api.retweets(ID) 

# printing the screen names of the retweeters 
for retweet in retweets_list: 
print(retweet.user.screen_name) 

有人能帮我吗?

要从推文列表中获取转发,您需要迭代推文ID列表,并依次为每个推文调用api.retweets函数。


如果你的推文本身有超过100条转发,你将达到API的限制。

根据Tweepy文档:

API.转发(id[,count](

返回给定推文的前100次转发。

Twitter API本身只支持检索多达100条转发,请参阅API文档(这与Tweepy调用的API相同(:

获取状态/转发/:id

返回id参数指定的推文的100条最新转发的集合。

这对我有效:

for retweet in retweets_list: 
print (retweets_list.retweet_count)

最新更新