kokochopper
kokochopper

Reputation: 39

How to search tweets based on tweet-id in Python?

I got a dataset that only has tweet-ids like "1300747127350423552", can I search tweets from these in Python? I tried this code:

tweet = api.statuses_lookup(['1300747127350423552']) a1[0].text

but it didn't work.

Upvotes: 0

Views: 236

Answers (1)

lb_so
lb_so

Reputation: 146

I can search for that ID and get results using TWEEPY. I will refrain from posting results due to privacy concerns.

import tweepy
   
def searchtweet():
    twitter_auth_keys = {
        "consumer_key": "yours goes here",
        "consumer_secret": "yours goes here",
        "access_token": "yours goes here",
        "access_token_secret": "yours goes here"
    }
  

    auth = tweepy.OAuthHandler(
        twitter_auth_keys['consumer_key'],
        twitter_auth_keys['consumer_secret']
    )
    auth.set_access_token(
        twitter_auth_keys['access_token'],
        twitter_auth_keys['access_token_secret']
    )

    api = tweepy.API(auth)

    print(api.statuses_lookup(["INSERT YOUR SEARCH TWEET ID HERE"]))

def main():
    searchtweet()

Upvotes: 1

Related Questions