ad-m / python-anticaptcha

Client library for solve captchas with Anticaptcha.com support.
http://python-anticaptcha.readthedocs.io/en/latest/
MIT License
223 stars 51 forks source link

Extract sitekey with python using re.search #39

Closed MacMarde closed 5 years ago

MacMarde commented 5 years ago

@ad-m Hi Adam, you already helped me a lot integrating your python code to use with selenium/chrome.

Now I do have another recaptcha, where I am not able to handle it.

First of all I am trying to extract sitekey. This was your code for the last recaptcha:

site_key = re.search("captchaSitekey = '(.+?)'",driver.page_source).group(1)

I dont understand how to use the re.search. It's really difficult for me to understand the syntax. But I guess this time its more complicated, because the sitekey can not be found in the page_source. Take a look here:

grafik

It seems like "sitekey" is inside of a javascript function. I hope you will help me again.

ad-m commented 5 years ago

I am out of office, but small help.

Here is regexp tutorial: https://medium.com/factory-mind/regex-tutorial-a-simple-cheatsheet-by-examples-649dc1c3f285

Regexp is about how to extract data from text.

Could you provide me link to that page & how to trigger recaptcha?

MacMarde commented 5 years ago

There is a very long link, but its surely temporarily and its identifiable. I hope I don't get blocked on the site for posting it here.

I post it here:

I don't know how long the link will be valid. I have tried it to open with different browser and IPs and seems to work for now.

ad-m commented 5 years ago

See there: https://github.com/ad-m/python-anticaptcha/pull/38/commits/a41133985e07eb695011bdab8c95932cddf6195a :smiley_cat:

MacMarde commented 5 years ago

Wow thats fantastic. Thank you very much. I could not have done this. You are a python genius.

I will test it soon and let you know if its working for me.

MacMarde commented 5 years ago

I justed wanted to test your code. But my account got banned. That is what I was afraid of. Propably no good idea to click this temporarily recaptcha link from different IP locations. It is no problem I will make a new account and test it.

ad-m commented 5 years ago

Is there anything what I can do for you?

MacMarde commented 5 years ago

@ad-m No thank you. I am still testing. Until now with the new account the recaptcha did not appear again. I will let you know if its working when the captcha appears again.

MacMarde commented 5 years ago

@ad-m I need your help again. I have tested it but the captcha is not solved. The sitekey extraction is working fine and I am also getting a valid token. Also the Javascripts are executed and everything is running without errors. But the recaptcha just does not disappear. It seems like the site just gets reloaded and the recaptcha just reappears. Where in your code gets the check box clicked? Or is this not neccessary?

ad-m commented 5 years ago

There is no need to get checkbox clicked. I call callback function for form submission.

Could you anyway provide new URL to verify what is missing?

MacMarde commented 5 years ago

I now completely observed the process. It seems like the site won't reload, instead just nothing happens. In debug I can see everything looks good (sitekey, token, no exceptions) but it is not going on. Also on my Anticaptcha Dashboard History window I can see some solved "I'm not a robot" recaptchas. So it seems like everything is working, but the recaptcha is not submitted. I will post the URL if I see the recaptcha again. I need to restart now and check. I am running selenium chrome with proxy. Maybe it would be a good idea if you test it with the same proxy (at least my account probably don't gets banned again this way)? I don't know if you want to or if it makes sence but if you want just give me your IP so I can add your IP to the authorized IPs of my proxy service provider.

MacMarde commented 5 years ago

New linke here

If you don't want to use proxy or you don't think it makes sence just use the link like you want, else just give me you IP.

MacMarde commented 5 years ago

@ad-m What do you think? Any progress?

MacMarde commented 5 years ago

I am testing atm. It seems like there are more than one recaptcha. This means my program needs to solve multiple recaptchas in a while loop until the recaptchas disappear. Could this be?

ad-m commented 5 years ago

Today I can not take care of it. It is possible that there are many captcha images. I'll take care of it during the weekend.

MacMarde commented 5 years ago

Ok let me know if you need a new link. Might be the link is not valid any more.

I have tried to get behind the recaptcha. Im not sure if its working. I am getting upto 4 recaptchas in one row. Site is relaoding each time after captcha is solved by your code, but either the next same recaptcha appears or an error message from the website entertainow.com . The error message is not from google, so I really don't know if its working or not. I will try it again today. Maybe I can get behind the recaptchas. I am waiting for your help on weekend.

MacMarde commented 5 years ago

Just to keep you updated: I have tried to solve captcha with your code about 30 times. It was not working. Now I did let the chrome extension from Anticaptcha solve the recaptcha and it was directly working with the first recapctha. One difference I have noticed: After the extension solved the recaptcha a blue check appeared in the check box, like it has been clicked. In your code no blue chechk appears. So now we know your code is not working for me. But I still would prefer your code if possible, because its a cleaner solution I guess. I believe the problem happens with the submitting of the token. But if possible I want to avoid loosing this account again. Would be nice if you could use my proxy to test it.

MacMarde commented 5 years ago

Maybe instead of a working code solution I would also be glad if you can give me informations about how I can find out how to do it on my own. What are the basics? Is there a good documentation with examples anywhere? I understand that I do have to inject the token somwhere in the HTML code and send it back to google somehow. This is what the javascript functions do. But how to find out where to inject and which function to call?

ad-m commented 5 years ago

What are the basics? Is there a good documentation with examples anywhere? I understand that I do have to inject the token somwhere in the HTML code and send it back to google somehow. This is what the javascript functions do. But how to find out where to inject and which function to call?

I set these values based on a thorough tracking of JavaScript code. It requires knowledge of JavaScript. I don't have general solution yet, but on each requests I attempt to make it more & more generic.

Would be nice if you could use my proxy to test it.

92.222.22.91

After the extension solved the recaptcha a blue check appeared in the check box, like it has been clicked. In your code no blue chechk appears.

It's just a form of presentation. It does not affect the way of communication with the server and the operation of the target server.

I am getting upto 4 recaptchas in one row. Site is relaoding each time after captcha is solved by your code, but either the next same recaptcha appears or an error message from the website entertainow.com

Multiple captcha in a row support in the given example script is not supported. I am not able to obtain such a situation on any of the given links, hence I am asking for information on obtaining fresh addresses using your proxy. My VPN IP address is above.

MacMarde commented 5 years ago

Thanks for your answer.

As I wrote you there are not really multiple captchas in one row. They only reappear because soving with your code did not work. The same captcha was solved on the first try with the antcpta chrome extensions.

At the moment I don't have any captchas to send you a link. I need to turn off antcpta chrome extension and wait for a new recapthca to appear. I will send you the link once it appears again and give you the proxy IP.

MacMarde commented 5 years ago

One thing I have thought about: Could it be this line of code has one comma too much: callback_function = re.search('(CAPTCHA_IMMEDIATE.+?),', driver.page_source).group(1)

whats about (one comma removed)?: callback_function = re.search('(CAPTCHA_IMMEDIATE.+?)', driver.page_source).group(1)

MacMarde commented 5 years ago

New linke here

If you don't want to use proxy or you don't think it makes sence just use the link like you want, else just give me you IP.

Ah wait I see the old link is tsill working *wondering. Just use this proxy: 192.126.238.3:3128

MacMarde commented 5 years ago

I am an idiot I wanted to click on "comment" not on "close and comment".

MacMarde commented 5 years ago

@ad-m Any progress?

ad-m commented 5 years ago

With the use of your proxy using the given address and MANUAL performing task I can only get the following message: obraz

Can you catch me on Gitter ( https://gitter.im/python-anticaptcha/Lobby ), so that we can explain it efficiently? I propose 7:00 UTC 11 July 2019.

MacMarde commented 5 years ago

@ad-m Well this error message does appear often on this website. It is not necessary linked to a recaptcha solving error.

I joined gitter and wrote a message to you.

NEOdinok commented 2 years ago

@MacMarde @ad-m Have you guys solved this issue ? I'm trying to write binance bot for myself and i'm confused with how to get "x-nft-checkbot-token" and "x-nft-checkbot-sitekey"

ad-m commented 2 years ago

I'm trying to write binance bot for myself

I am curious why do you need to handle captcha for that? Binance have official API and there is unofficial SDK: https://python-binance.readthedocs.io/en/latest/