pythontwittertweepypraw

Getting a tweet id from a tweet link using Tweepy


I am creating a bot for Reddit that posts a tweet's text, author, and a couple of other small things on submissions that directly link to the tweet (example - https://twitter.com/John_Yuki_Bot/status/889453450664304641).

However, I can't find anything in the Tweepy documentation that lets me extract a tweet's id from a tweet link so that I can use api.get_status(status_id) in order to get the status text, status author, and so on.

How can I get the status id just using links like that?

EDIT - The code at the end of the link (889453450664304641) is the status ID. I need to have this in its own variable so that Tweepy can use it.


Solution

  • Simple

    url.split('/')[-1]
    

    and you get what you want