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

Unable to login accounts. #45

Closed
stygmate opened this issue Jul 26, 2023 · 15 comments
Closed

Unable to login accounts. #45

stygmate opened this issue Jul 26, 2023 · 15 comments
Labels
bug Something isn't working Stale

Comments

@stygmate
Copy link
Contributor

i'm using 0.6
i'm unable to login accounts.
the only way working is copy pasting cookies, which is pretty annoying and slow to do when adding accounts.

@dwicak
Copy link

dwicak commented Jul 26, 2023

i'm using 0.6
i'm unable to login accounts.
the only way working is copy pasting cookies, which is pretty annoying and slow to do when adding accounts.

Can you tell me how to copy-pasting cookies? Because my login also didn't work.

@rulas99
Copy link

rulas99 commented Jul 26, 2023

I have the same problem, i tried with different accounts and always get the same error message:

NameError: name 'a' is not defined

@stygmate
Copy link
Contributor Author

stygmate commented Jul 26, 2023

Can you tell me how to copy-pasting cookies? Because my login also didn't work.

@dwicak Login to a account with your browser, open developement tools, find the main request informations, copy the cookie header string of this request and paste it in the cookie parameter of the add_account function.

@GinaMhd
Copy link

GinaMhd commented Jul 27, 2023

Im trying to follow your instructions but Im getting this error:

twscrape.imap:imap_try_login:97 - Error logging into email_account@yahoo.com on imap.mail.yahoo.com: b'[AUTHENTICATIONFAILED] LOGIN Invalid credentials'

2023-07-27 11:58:37.452 | ERROR | twscrape.accounts_pool:login:140 - Error logging in to twitter_account: command SELECT illegal in state NONAUTH, only allowed in states AUTH, SELECTED

Do you know how to solve this?Thanks!

@dwicak
Copy link

dwicak commented Jul 29, 2023

Can you tell me how to copy-pasting cookies? Because my login also didn't work.

@dwicak Login to a account with your browser, open developement tools, find the main request informations, copy the cookie header string of this request and paste it in the cookie parameter of the add_account function.

Can you copy and paste your code, of course, without your valid cookies? I still don't understand.

@stygmate
Copy link
Contributor Author

@dwicak it's in the readme of the repo.

await api.pool.add_account("user3", "pass3", "u3@mail.com", "mail_pass3", cookies=cookies)

@vladkens vladkens added the bug Something isn't working label Jul 30, 2023
@vladkens
Copy link
Owner

Hi there. I restore behaviour from v0.5.0, now possible again to pass login flow without email / email_password. Email check before login can be done with email_first param in login method or --email-first from cli.

See changelog: https://github.com/vladkens/twscrape/releases/tag/v0.7.0

@vladkens
Copy link
Owner

Im trying to follow your instructions but Im getting this error:

twscrape.imap:imap_try_login:97 - Error logging into email_account@yahoo.com on imap.mail.yahoo.com: b'[AUTHENTICATIONFAILED] LOGIN Invalid credentials'

2023-07-27 11:58:37.452 | ERROR | twscrape.accounts_pool:login:140 - Error logging in to twitter_account: command SELECT illegal in state NONAUTH, only allowed in states AUTH, SELECTED

Do you know how to solve this?Thanks!

This looks like email blocked. If it not tell more details, please.

@vladkens
Copy link
Owner

Can you tell me how to copy-pasting cookies? Because my login also didn't work.

@dwicak Login to a account with your browser, open developement tools, find the main request informations, copy the cookie header string of this request and paste it in the cookie parameter of the add_account function.

Can you copy and paste your code, of course, without your valid cookies? I still don't understand.

  1. Open https://twitter.com/
  2. Click right click anywhere on the page > Inspect (last item in menu)
  3. Click Console in the top
  4. Type document.cookie and press enter
  5. Copy string result
image

Other way:

  1. Open https://twitter.com
  2. Type into url: javascript:window.prompt("Cookies:", document.cookie) (type javascript: manually because browser will cut off it) and press enter
  3. Copy cookies & paste where you need this

Note: You can add this code as bookmark

One more way:
Use extensions like https://chrome.google.com/webstore/detail/%E3%82%AF%E3%83%83%E3%82%AD%E3%83%BCjson%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E5%87%BA%E5%8A%9B-for-puppet/nmckokihipjgplolmcmjakknndddifde

@dwicak
Copy link

dwicak commented Aug 2, 2023

Can you tell me how to copy-pasting cookies? Because my login also didn't work.

@dwicak Login to a account with your browser, open developement tools, find the main request informations, copy the cookie header string of this request and paste it in the cookie parameter of the add_account function.

Can you copy and paste your code, of course, without your valid cookies? I still don't understand.

  1. Open https://twitter.com/
  2. Click right click anywhere on the page > Inspect (last item in menu)
  3. Click Console in the top
  4. Type document.cookie and press enter
  5. Copy string result
image Other way:
  1. Open https://twitter.com
  2. Type into url: javascript:window.prompt("Cookies:", document.cookie) (type javascript: manually because browser will cut off it) and press enter
  3. Copy cookies & paste where you need this

Note: You can add this code as bookmark

One more way: Use extensions like https://chrome.google.com/webstore/detail/%E3%82%AF%E3%83%83%E3%82%AD%E3%83%BCjson%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E5%87%BA%E5%8A%9B-for-puppet/nmckokihipjgplolmcmjakknndddifde

Thank you. I can add accounts using cookies now. But I got an error like this:

2023-08-02 14:50:21.928 | INFO | twscrape.accounts_pool:get_for_queue_or_wait:260 - No account available for queue "SearchTimeline". Next available at 01:06:35

I tried to google the error but didn't find anything.

@GunduzYuruyen
Copy link

No account available for queue "SearchTimeline".

Did you find a solution for this?

@NoPurposeInLife
Copy link

It means your accounts has reached its limit for requests, just wait 15 mins, it says Next available at 01:06:35 on GMT timezone, so just wait and it'll start scraping again 👍

@feesgo
Copy link

feesgo commented Jan 5, 2024

I login in my browser to twitter

I create the file accounts.txt

whit this structure:

my_twitter_user:my_twitter_password:my_twitter_email:my_twitter_password:cookie_value_from_my_browser_according_to_this guide

The guide to get twitter cookie value:
#45

from command line login to twitter using twscrape

with this command:

twscrape add_accounts ./accounts.txt username:password:email:email_password:cookies

It will appear a login confirmation:

Account your_twitter_account added successfully (active=False)

twscrape will create the file

accounts.db

with login credentials

from command line validate login to twitter from twscrape with the command:

twscrape login_accounts

It will appear a confirmation:

2024-01-05 10:57:53.774 | INFO | twscrape.accounts_pool:login_all:155 - [1/1] Logging in your_twitter_account - your_twitter_email
2024-01-05 10:57:55.072 | INFO | twscrape.accounts_pool:login:138 - Logged in to your_twitter_account successfully

from command line validate login to twitter from twscrape with the command:

twscrape accounts

It will appear a confirmation:

username logged_in active last_used total_req error_msg
your_twitter_account 1 1 None 0 None

get twitter messages from an user and save it to a file:

twscrape user_tweets 82119937 --limit=200 > amlo.txt

The file amlo.txt will be created twitter messages from an user

For example:

{"id": 1736459471994679567, "id_str": "1736459471994679567", "url": "https://twitter.com/lopezobrador_/status/1736459471994679567", "date": "2023-12-17 18:52:54+00:00", "user": {"id": 82119937, "id_str": "82119937", "url": "https://twitter.com/lopezobrador_", "username": "lopezobrador_", "displayname": "Andr\u00e9s Manuel", "rawDescription": "Presidente Constitucional de los Estados Unidos Mexicanos", "created": "2009-10-13 15:28:01+00:00", "followersCount": 10376407, "friendsCount": 293, "statusesCount": 7236, "favouritesCount": 79, "listedCount": 11381, "mediaCount": 1910, "location": "M\u00e9xico", "profileImageUrl": "https://pbs.twimg.com/profile_images/1433234061691084800/8TUii2rl_normal.jpg", "profileBannerUrl": "https://pbs.twimg.com/profile_banners/82119937/1674777233", "protected": null, "verified": false, "blue": true, "blueType": "Government", "descriptionLinks": [{"url": "http://presidente.gob.mx", "text": "presidente.gob.mx", "tcourl": "https://t.co/zNEOKC7CnT"}], "_type": "snscrape.modules.twitter.User"}, "lang": "es", "rawContent": "En el \u00faltimo tramo de nuestro gobierno estamos terminando obras importantes: ya inauguramos el aeropuerto de Tulum y la primera etapa del Tren Maya; ayer se concluy\u00f3 el acueducto El Cuchillo II para abastecer con 5 mil litros adicionales por segundo a la zona conurbada de Monterrey. Tambi\u00e9n por la tarde inauguramos un regimiento para m\u00e1s de 500 elementos en Nuevo Laredo, donde avanza la construcci\u00f3n de las oficinas centrales para el manejo de aduanas del pa\u00eds. Ma\u00f1ana inauguramos la presa Santa Mar\u00eda en Sinaloa; el 21, la primera etapa del acueducto Agua Saludable para La Laguna; el 22 empieza a operar el Tren del Istmo; el 26 vuelve a volar Mexicana de Aviaci\u00f3n; el 27 inauguramos la primera etapa del acueducto de la presa El Zapotillo, que llevar\u00e1 agua a Guadalajara; el 28, nada porque es el D\u00eda de los Inocentes; el 29, la farmacia central con todos los medicamentos en Huehuetoca y el 31 se inaugura la segunda etapa del Tren Maya, de Canc\u00fan a Palenque, y feliz a\u00f1o.", "replyCount": 2812, "retweetCount": 6127, "likeCount": 15938, "quoteCount": 367, "conversationId": 1736459471994679567, "hashtags": [], "cashtags": [], "mentionedUsers": [], "links": [], "viewCount": 931993, "retweetedTweet": null, "quotedTweet": null, "place": null, "coordinates": null, "inReplyToTweetId": null, "inReplyToUser": null, "source": "<a href="https://mobile.twitter.com\" rel="nofollow">Twitter Web App", "sourceUrl": "https://mobile.twitter.com", "sourceLabel": "Twitter Web App", "media": {"photos": [], "videos": [{"thumbnailUrl": "https://pbs.twimg.com/media/GBkod3lboAAoW6v.jpg", "variants": [{"contentType": "video/mp4", "bitrate": 256000, "url": "https://video.twimg.com/ext_tw_video/1736456400241557504/pu/vid/avc1/480x270/QrgY3-nva0TOFl99.mp4?tag=12"}, {"contentType": "video/mp4", "bitrate": 832000, "url": "https://video.twimg.com/ext_tw_video/1736456400241557504/pu/vid/avc1/640x360/5OICodSEhpSqsgTn.mp4?tag=12"}, {"contentType": "video/mp4", "bitrate": 2176000, "url": "https://video.twimg.com/ext_tw_video/1736456400241557504/pu/vid/avc1/1280x720/764HjDuDj7RkYIZ8.mp4?tag=12"}], "duration": 215633, "views": null}], "animated": []}, "_type": "snscrape.modules.twitter.Tweet"}

Before using twscrape you should check if you are still login in to your twitter in your browser

I you log off from your browser to twitter, you cannnot use twscrape from command line anymore...

I you log off from your browser to twitter, then login again, you cannnot use twscrape from command line anymore... (Because the cookie used has changed)

It would appear this error:

2023-08-02 14:50:21.928 | INFO | twscrape.accounts_pool:get_for_queue_or_wait:260 - No account available for queue "SearchTimeline". Next available at 01:06:35

I you log off from your browser to twitter, then login again, you cannnot use twscrape from command line anymore... (Because the cookie used has changed)

a)

You can delete the file

accounts.db

b)
you can update the file accounts.txt

whit this structure:

my_twitter_user:my_twitter_password:my_twitter_email:Tabasco.tr.2099:my_twitter_password:cookie_value_from_my_browser_according_to_this guide

The guide to get twitter cookie value:
#45

Copy link

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 github-actions bot added the Stale label Feb 12, 2024
Copy link

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

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Stale
Projects
None yet
Development

No branches or pull requests

8 participants