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

Failed to login to ACCOUNT: [Errno -2] Name or service not known #145

Closed jemather closed 7 months ago

jemather commented 8 months ago

I've been trying to add user-level proxies for accounts using this setup following from the Proxy examples:

async def main():
    api = API()
    proxy = "http://USER:PASS@1.1.1.1:1111"
    await api.pool.add_account(username,twitterpass,email,email_pass, proxy=proxy)
    await api.pool.login_all()

if __name__ == "__main__":
    asyncio.run(main())

After adding the accounts this way and trying to login, for every account I get the error: Failed to login to USERNAME: [Errno -2] Name or service not known

I've used the proxies with requests with no issues, and tried with several different proxies so I don't think that's the source of the issue.

jemather commented 8 months ago

Update - based on the error I was receiving, I think it was related to logging into the email server to get the verification code. Maybe its trying to log in to the email server with the proxy and that's not working right? I was able to work around it by logging in manually and using a cookie.

vladkens commented 7 months ago

Yes, most likely a proxy error.

jemather commented 6 months ago

To get around it, I signed in manually with the proxy, then extracted the ct0 and auth_token cookies. Then, when I added the account, I included the proxy:

proxy = "http://{}:{}@{}:{}".format(proxy_user, proxy_pass, proxy_host, proxy_port) await api.pool.add_account(twitter_username, twitter_password, email, email_pass, cookies = cookies, proxy=proxy) await api.pool.relogin(twitter_username)

On Wed, May 8, 2024 at 7:43 PM Patricio Segovia @.***> wrote:

I have the same problem:

@.:/home/newsearch# twscrape login_accounts 2024-05-08 20:35:53.352 | INFO | twscrape.accounts_pool:login_all:183 - [1/3] Logging in account1 - @. 2024-05-08 20:35:54.329 | ERROR | twscrape.accounts_pool:login:165 - Failed to login 'account1': [Errno -2] Name or service not known 2024-05-08 20:35:54.348 | INFO | twscrape.accounts_pool:login_all:183 - [2/3] Logging in account2 - @. 2024-05-08 20:35:55.488 | INFO | twscrape.accounts_pool:login:158 - Logged in to account2 successfully 2024-05-08 20:35:55.505 | INFO | twscrape.accounts_pool:login_all:183 - [3/3] Logging in account3 - @. 2024-05-08 20:35:56.513 | ERROR | twscrape.accounts_pool:login:165 - Failed to login 'account3': [Errno -2] Name or service not known {'total': 3, 'success': 1, 'failed': 2}

What im doing wrong?

— Reply to this email directly, view it on GitHub https://github.com/vladkens/twscrape/issues/145#issuecomment-2101723495, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADNNJR4LOLFUTWV7PE6MO7DZBLBDRAVCNFSM6AAAAABEYPQTAOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBRG4ZDGNBZGU . You are receiving this because you authored the thread.Message ID: @.***>