vladkens / twscrape

2024! 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
784 stars 102 forks source link

Issue with logging in #200

Open raghdaa-ahmed opened 2 weeks ago

raghdaa-ahmed commented 2 weeks ago

I have been using snscrape until last year (before it stopped working) and I recently found out about this package so thank you for this, it looks promising. I am a data analyst with no deep programming knowledge so excuse me if the questions are silly.

I have installed twscrape but I have an issue logging in at this step.

await api.pool.add_account("user1", "pass1", "u1@example.com", "mail_pass1")
await api.pool.add_account("user2", "pass2", "u2@example.com", "mail_pass2")
await api.pool.login_all()

1- Is it safe to just type my passwords in the code at this step? Because the email I use for my twitter account is an important email for me.

2- Should I use 2 accounts or is using 1 account only ok?

3- I tried logging into one account and I got this. I entered the username and password of an existing account and the email associated with that account and the password of that email. Am I doing this right?

2024-06-10 01:06:41.586 | WARNING | twscrape.accounts_pool:add_account:88 - Account "my_username" already exists 2024-06-10 01:06:41.596 | WARNING | twscrape.accounts_pool:get_for_queue_or_wait:297 - No active accounts. Stopping... 2024-06-10 01:06:41.605 | WARNING | twscrape.accounts_pool:get_for_queue_or_wait:297 - No active accounts. Stopping..

LucasLeRay commented 5 days ago

1- As for any programming project, it's a bad practice to write your emails and passwords in code. A preferred approach is to populate them through environment variables or, even better, using dedicated secrets storages. But more generally for scraping I don't recommend using your personal "important" email. It could be locked by Twitter.

2- Using 1 account is fine, but you'll be limited in the number of operations per 15m you can do. Additionally, Twitter is pretty good at identifying scrapers, so if your single account is caught by Twitter, your program will stop working. It's better to have multiple accounts and replace them when caught.

3- Can you show us the specific piece of code you used?