vladkens / twscrape

2024! X / Twitter API scrapper with authorization support. Allows you to scrape search results, User's profiles (followers/following), Tweets (favoriters/retweeters) and more.
https://pypi.org/project/twscrape/
MIT License
1.12k stars 133 forks source link

[Feature request] Exit when no good account instead of waiting, for AWS Lambda #148

Closed vsnig closed 7 months ago

vsnig commented 8 months ago

I think we need an option to just exit when there's no good account. It's appropriate when running on AWS Lambda

P.S. now I'm thinking that probably the best option is to raise an Exception. This way we can use Lambda's native retry mechanism, or catch and ignore or react the way we wish

github-actions[bot] commented 7 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

vladkens commented 7 months ago

Will be added in v0.12.

Usage:

from twscrape import API, NoAccountError

api = API(raise_when_no_account=True)
try:
    api.search("foo", limit=10)
except NoAccountError:
    pass

Or with environment variable:

TWS_RAISE_WHEN_NO_ACCOUNT=1 twscrape tweet_details 1778577341163110904