-
I have 500 Tweet ids and try to collect 3200 recent tweets from each tweet_id. The below is my code. but the problem is that it doesn't move on but stuck at some tweet that I am trying to collect.. On my termial, It keep iterating and shows me that My code is like as below: def get_all_tweets(screen_name):
if name == 'main': |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
https://twitter.com/halfbare seems to only have around that many Tweets: >>> user = api.get_user("halfbare")
>>> user.statuses_count
1550 Once your code reaches their earliest Tweet (which seems to be https://twitter.com/halfbare/status/1117195540448432128), your call to You should look into using a Cursor object to paginate instead. For code block usage, see https://docs.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks. |
Beta Was this translation helpful? Give feedback.
https://twitter.com/halfbare seems to only have around that many Tweets:
Once your code reaches their earliest Tweet (which seems to be https://twitter.com/halfbare/status/1117195540448432128), your call to
API.user_timeline
will return an empty list since there are no older Tweets. Therefore,alltweets
remains the same size, under 3200, and your while loop loops infinitely and spams requests to Twitter's GET statuses/user_timeline endpoint.You should look into using a Cursor object to paginate instead.
See https://tweepy.readthedocs.io/en/latest/cursor_tutorial.html.
For code block usage, see https://docs.github.com/en/gi…