简体   繁体   中英

Tweepy - Get Id of retweeted tweet

Does anyone know how this is done? I'm trying to get the id of the original tweet. So if someone retweets something, I want to find what they retweeted. This is what I have to determine what is retweeted or not:

if hasattr(status, 'retweeted_status'): #if not rt'd
        #something
else:                                   #if rt'd
        #something

The field retweeted_status contains the representation of the original tweet that was retweeted to generate the status object you have with you. So every field that is present in a twitter status object is included as such in the retweeted_status field. Now all you have to do is to get them like

status.retweeted_status.id_str

to get the id of the parent tweet, for instance. Simply modify this accordingly to get whatever field you need from the parent tweet.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM