How can I get tweets older than a week (using tweepy or other python libraries)

后端 未结 8 520
予麋鹿
予麋鹿 2020-11-27 02:55

I have been trying to figure this out but this is a really frustrating. I\'m trying to get tweets with a certain hashtag (a great amount of tweets) using Tweepy. But this do

相关标签:
8条回答
  • 2020-11-27 03:22

    2018 update: Twitter has Premium search APIs that can return results from the beginning of time (2006):

    https://developer.twitter.com/en/docs/tweets/search/overview/premium#ProductPackages

    Search Tweets: 30-day endpoint → provides Tweets from the previous 30 days.

    Search Tweets: Full-archive endpoint → provides complete and instant access to Tweets dating all the way back to the first Tweet in March 2006.

    With an example Python client: https://github.com/twitterdev/search-tweets-python

    0 讨论(0)
  • 2020-11-27 03:24

    Found one code that would help retrieve older tweets. https://github.com/Jefferson-Henrique/GetOldTweets-python

    To get old tweets, run the following command in the directory where the code repository got extracted.

    python Exporter.py --querysearch 'keyword' --since 2016-01-10 --until 2016-01-15 --maxtweets 1000
    

    And it returned a file 'output_got.csv' with 1000 tweets during the above days with your keyword

    You need to install a module 'pyquery' for this to work

    PS: You can modify 'Exporter.py' python code file to get more tweet attributes as per your requirement.

    0 讨论(0)
  • 2020-11-27 03:29

    As others have noted, the Twitter API has the date limitation, but not the actual advanced search as implemented on twitter.com. So so the solution is to use Python's wrapper for Selenium or PhantomJS to iterate through the twitter.com endpoint. Here's an implementation using Selenium that someone has posted on Github: https://github.com/bpb27/twitter_scraping/

    0 讨论(0)
  • 2020-11-27 03:30

    You can use the Rest APIs to get tweets older than a week For more details visit the twitter API reference https://dev.twitter.com/rest/reference/get/statuses/user_timeline

    0 讨论(0)
  • 2020-11-27 03:32

    As you have noticed Twitter API has some limitations, I have implemented a code that do this using the same strategy as Twitter running over a browser. Take a look, you can get the oldest tweets: https://github.com/Jefferson-Henrique/GetOldTweets-python

    0 讨论(0)
  • 2020-11-27 03:34

    Knowing this is a very old question but still, some folks might be facing the same issue. After some digging, I found out Tweepy's search only returns data for the past 7 days and that some times lead to buy third party service. I utilised python library, GetOldTweets3 and it worked fine for me. The utility of this library is really easy. The only limitation of this library that we can't search for more than one hashtag in one execution but it works fine to search for multiple accounts at the same time.

    0 讨论(0)
提交回复
热议问题