I want to scrape first 200 replies (text, number of like, date...) from a tweet of April 2022 and save these data in a dataframe named 'replies1_apr_22.csv' but snscrape library for some reason is not working. Maybe the data I want to retrieve is too old.
Tweet id is 1520534341951971328 You can read tweet and replies here "https://twitter.com/elonmusk/status/1520534341951971328"
Below you can see my code and my error
CODE
import snscrape.modules.twitter as sntwitter
tweets_list = []
limit = 200
def get_specific_tweet(tweet_id):
print(tweet_id)
for i, tweet in enumerate(sntwitter.TwitterTweetScraper(tweetId=tweet_id,
mode=sntwitter.TwitterTweetScraperMode.SCROLL).get_items()):
if len(tweets_list) == limit:
break
else:
print(tweet)
tweets_list.append([i+1, tweet.date, tweet.user.username, tweet.content,
tweet.user.friendsCount, tweet.user.favouritesCount,
tweet.replyCount, tweet.retweetCount, tweet.likeCount, tweet.lang,
tweet.inReplyToUser, tweet.mentionedUsers, tweet.hashtags, tweet.cashtags])
print(tweets_list)
get_specific_tweet(tweet_id=1520534341951971328)
df = pd.DataFrame(tweets_list, columns=['n', 'Date', 'User', 'Tweet', 'Friends', 'User_Like',
'Replies', 'Retweet', 'Like', 'Language', 'Reply_to',
'Mentions', 'Hashtags', 'Cashtags'])
df.to_csv('replies1_apr_22.csv', index=False, encoding='utf-8')
ERROR
Traceback (most recent call last):
File "C:\Users\fabio\OneDrive\Desktop\Unipd\Tesi\Elon Musk\Twint.py", line 70, in <module>
get_specific_tweet(tweet_id=1520534341951971328)
File "C:\Users\fabio\OneDrive\Desktop\Unipd\Tesi\Elon Musk\Twint.py", line 63, in get_specific_tweet
tweets_list.append([i+1, tweet.date, tweet.user.username, tweet.content, tweet.user.followersCount,
AttributeError: 'Tombstone' object has no attribute 'date'
Hope you understand my problem
I was expecting open my csv file with 200 rows of data but is empty