'With a list of tweet IDs, using snscrape, how can I retrieve the contents of the tweets?

I have tried the following code adapted from the medium article. The list of tweet id's I want to find is in the csv file NAACL_SRW_2016.

%load new_scrapes.py
import snscrape.modules.twitter as sntwitter
import pandas as pd

# Creating list to append tweet data
tweets_list1 = []
df = pd.read_csv('C:\\Users\\NAACL_SRW_2016_20_twts.csv')
df.columns = ["tweet_ID", "label"]
tweet_id = df["tweet_ID"]
for tweet in (sntwitter.TwitterSearchScraper('tweetId:{}'.format(tweet_id)).get_items()):
        tweets_list1.append([tweet.date, tweet.id, tweet.content, tweet.user.username])

# Creating a dataframe from the tweets list above
tweets_df1 = pd.DataFrame(tweets_list1, columns=['Datetime', 'Tweet Id', 'Text', 'Username'])
#tweets_df1.head()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source