Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List support #20

Closed
codilau opened this issue Jun 25, 2023 · 7 comments
Closed

List support #20

codilau opened this issue Jun 25, 2023 · 7 comments

Comments

@codilau
Copy link

codilau commented Jun 25, 2023

Hey there, thanks for the good work.
For my use case i'd need to be able to scrape multiple lists.
Is there a way to ask the GraphQL endpoint instead of passing through the list:id search query?
thanks

@vladkens
Copy link
Owner

vladkens commented Jul 1, 2023

Hi, @codilau.

I haven't looked into it, but I've seen something like that in the API calls.

Do you have an example of a list in the twitter interface (web app) so we can see what requests the tweeter makes to its API and add this to the library?

I personally don't use twitter enough, so I'm not very familiar with all its functions.

@codilau
Copy link
Author

codilau commented Jul 2, 2023

Hi, thanks for looking into this subject. It's helpful to have this feature because it allows curated content with very few api calls.
The example uri looks like this : "https://twitter.com/i/lists/1494877848087187461" A list can have up to 5k accounts.
There is the possibility to use the search query "list:1494877848087187461", but it would make more sense not to use that endpoint if a dedicated one exists in their graphQL implementation.
Of course, I'm unsure if any of this is relevant now since Elon has a hard-on on scraping.
Again, thanks for your work!

@codilau
Copy link
Author

codilau commented Jul 3, 2023

Digging in a bit i found this:
endpoint = "/graphql/ZBbXrl37E6za5ml-DIpmgg/ListLatestTweetsTimeline"

@vladkens
Copy link
Owner

vladkens commented Jul 6, 2023

Hi, @codilau.

Thanks for the explanation. I will try to add this functionality as soon as possible.

So, API should be like:

async for tweet in api.list_timeline(LIST_ID, limit=100):
    print(tweet.id)

Its right?

@codilau
Copy link
Author

codilau commented Jul 6, 2023

@vladkens absolutely, thanks!

vladkens added a commit that referenced this issue Jul 6, 2023
@vladkens
Copy link
Owner

vladkens commented Jul 7, 2023

Hi, @codilau.

Added lists support to v0.5.0, update please:

pip install --upgrade twscrape

Then:

twscrape list_timeline 1494877848087187461
twscrape list_timeline 1494877848087187461 --raw

Or from code:

async for tweet in api.list_timeline(1494877848087187461):
    print(tweet.id)

@codilau
Copy link
Author

codilau commented Jul 7, 2023

wonderful, thank you @vladkens!

@codilau codilau closed this as completed Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants