Search code examples
pythonapitweepy

try to extract one tweet's id information after creating an API object


I'm still new in python and i was trying to extract one tweet's id information after creating an API object. so the code was :

import tweepy
consumer_key = 'hidden'
consumer_secret = 'hidden'
access_token = 'hidden'
access_secret = 'hidden'

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)

api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True)

# to test it
exp_tweet = api.get_status(archive.tweet_id[1000], tweet_mode = 'extended')
content = exp_tweet._json
Content

the output is :

NameError: name 'archive' is not defined
[enter image description here][1]

Solution

  • If I take this tweet, I can find it's id in the URL witch is "1294917318405836802"

    You can update your code and try to retrieve it

    id_ = "1294917318405836802"
    exp_tweet = api.get_status(id_, tweet_mode = 'extended')
    content = exp_tweet._json