Hello,
I want to scrape all tweets of a specific twitter list (e.g. list ID: i/lists/91224190900283392)
Is there a way to do this?
If I scrape the tweets of the “@wahlbeobachter”, I only get the tweets that this person has created. So how do I have to change the query from the screenshot?
Thanks in advance!
Regards,
Moxinator
You can only get the latest 800 tweets of a list with GET /2/lists/:id/tweets | Docs | Twitter Developer Platform so to get older tweets, you will have to enumerate all the members of a list with GET /2/lists/:id/members | Docs | Twitter Developer Platform and then use their handles to build a long query using OR operator like:
'(from:user1 OR from:user2 OR from:user3 OR from:user4) -is:retweet lang:de'
note that -is:retweet lang:de will alter the results and not give you the exact same tweets as the lists tweets endpoint - that returns everything from all the list members.
Thanks for answering!
I now have every user from the list.
Would you recommend iterate over all users stored in a list like here:
or would you use a query like:
'(from:user1 AND from:user2 AND from:user3 AND from:user4) -is:retweet lang:de'
(I would prefer the AND statement as I want all tweets from all users).
I would recommend the long query using OR to be more efficient with calls. So instead of a loop over the politicians with for politician in csu,
politicians = " OR ".join([f"from:{username}" for username in csu])
query = f'({politicians}) -is:retweet lang:de'
(I would prefer the AND statement as I want all tweets from all users).
AND is not a valid operator, a space is an implicit logical AND. The correct query to get all tweets from all users is to use OR because a tweet can only have 1 author so it can’t be from user1 AND user2 AND user3, see here on the logic and how to build queries: Search Tweets - How to build a query | Docs | Twitter Developer Platform
1 Like