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
793 stars 104 forks source link

having trouble logging into my twitter account using example code. #125

Closed pateyu closed 2 months ago

pateyu commented 4 months ago

I am using the example code and just running. I keep getting some errors. I will show my code and errors below. Please help. Note that I have censored my username and email.

Here is my code:


import asyncio
import twscrape
async def worker(api: twscrape.API, q: str):
    tweets = []
    try:
        async for doc in api.search(q):
            tweets.append(doc)
    except Exception as e:
        print(e)
    finally:
        return tweets
async def main():
    api = twscrape.API()  
    await api.pool.add_account("twitteruser", "twitterpass", "@gmail.com", "emailpass")
    await api.pool.login_all()
    queries = ["elon musk", "tesla", "spacex", "neuralink", "boring company"]
    results = await asyncio.gather(*(worker(api, q) for q in queries))
    combined = dict(zip(queries, results))
    for k, v in combined.items():
        print(k, len(v))
if __name__ == "__main__":
    asyncio.run(main())

here is my error:

twscrape.accounts_pool:login_all:166 - [1/1] Logging in mytwitteruser - myemail@gmail.com
2024-02-12 16:56:07.467 | ERROR    | twscrape.accounts_pool:login:148 - Failed to login to mytwitteruser: 'ct0'
2024-02-12 16:56:07.491 | WARNING  | twscrape.accounts_pool:get_for_queue_or_wait:271 - No active accounts. Stopping...
2024-02-12 16:56:07.494 | WARNING  | twscrape.accounts_pool:get_for_queue_or_wait:271 - No active accounts. Stopping...
2024-02-12 16:56:07.495 | WARNING  | twscrape.accounts_pool:get_for_queue_or_wait:271 - No active accounts. Stopping...
2024-02-12 16:56:07.496 | WARNING  | twscrape.accounts_pool:get_for_queue_or_wait:271 - No active accounts. Stopping...
2024-02-12 16:56:07.498 | WARNING  | twscrape.accounts_pool:get_for_queue_or_wait:271 - No active accounts. Stopping...
2024-02-12 16:56:07.504 | WARNING  | twscrape.accounts_pool:get_for_queue_or_wait:271 - No active accounts. Stopping...
2024-02-12 16:56:07.507 | WARNING  | twscrape.accounts_pool:get_for_queue_or_wait:271 - No active accounts. Stopping...
2024-02-12 16:56:07.509 | WARNING  | twscrape.accounts_pool:get_for_queue_or_wait:271 - No active accounts. Stopping...
2024-02-12 16:56:07.510 | WARNING  | twscrape.accounts_pool:get_for_queue_or_wait:271 - No active accounts. Stopping...
2024-02-12 16:56:07.511 | WARNING  | twscrape.accounts_pool:get_for_queue_or_wait:271 - No active accounts. Stopping...
elon musk 0
tesla 0
spacex 0
neuralink 0
boring company 0
chinmaychahar commented 4 months ago

I'm getting the same error. Did you find any work around?

Lazza commented 3 months ago

I got a similar error while trying to fiddle with the cookies.

Apparently my previous code injected wrong data that was cached in accounts.db. Removing the file and trying the code from scratch worked.

github-actions[bot] commented 2 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.

github-actions[bot] commented 2 months ago

This issue was closed because it has been stalled for 5 days with no activity.