iSarabjitDhiman / TweeterPy

TweeterPy is a python library to extract data from Twitter. TweeterPy API lets you scrape data from a user's profile like username, userid, bio, followers/followings list, profile media, tweets, etc.
MIT License
123 stars 17 forks source link

historical data #26

Closed CharlesFr closed 10 months ago

CharlesFr commented 10 months ago

I can see the following code returns the latest 100 tweets, it is possible to get more history?

from tweeterpy import TweeterPy

twitter = TweeterPy()

user = twitter.get_user_id("elonmusk")

tweets = twitter.get_user_tweets(user)

print(tweets)
iSarabjitDhiman commented 10 months ago

Hey @CharlesFr

Yes, you can fetch older tweets than just 100 latest ones. For that, you have to be logged in (try not to use your personal account). Twitter shows only a limited amount of data to the guest users. You can get as much as you want once you log in.

But you are talking about data like 5-10years old (like with the Official Twitter Historical API), that might not be possible yet unless you have that many twitter accounts to make requests. By default the tweets are sorted by time so going back to 5-10 years old tweets may take a while and you may end up getting your account banned if using only one account for scraping.