JustAnotherArchivist / snscrape

A social networking service scraper in Python
GNU General Public License v3.0
4.52k stars 712 forks source link

I can't get user retweets. #923

Closed AlesnarPro closed 1 year ago

AlesnarPro commented 1 year ago

Hello! I'm using snscrape.modules.twitter to scrape new tweets from users, but I'm having a problem, I can't find the user's retweets, only their original tweets. Maybe I'm doing something wrong, does snscrape have such an option? Here is my code:

import snscrape.modules.twitter as sntwitter

def get_latest_tweets(username, num_tweets):
     tweets = []
     for tweet in sntwitter.TwitterUserScraper(username).get_items():
         if tweet.inReplyToUser is None:
             tweets.append(tweet)
             if len(tweets) >= num_tweets:
                 break
     return tweets

username="elonmusk"
num_tweets = 5

latest_tweets = get_latest_tweets(username, num_tweets)

for tweet in latest_tweets:
     print(tweet.rawContent)
     print("---")
     print()
     print("---")
JustAnotherArchivist commented 1 year ago

887 #83