AndreiDrang / python3-anticaptcha

Python library for AntiCaptcha.
https://andreidrang.github.io/python3-anticaptcha/
MIT License
158 stars 39 forks source link

Token - Form submission returning "captcha wrong" #53

Closed adrianomaia closed 4 years ago

adrianomaia commented 4 years ago

First, thank's for this library.

I'm using the following code to bypass a "Recaptcha":

                ANTICAPTCHA_KEY = ''
                PAGE_URL = url
                SITE_KEY = site_key

                result = NoCaptchaTaskProxyless.NoCaptchaTaskProxyless(anticaptcha_key = ANTICAPTCHA_KEY)\
                .captcha_handler(websiteURL=PAGE_URL,
                             websiteKey=SITE_KEY)
                captcha_answer = result.get("solution").get("gRecaptchaResponse")
                if captcha_answer != "":
                    print(captcha_answer)
                    self.driver.execute_script("document.getElementById('g-recaptcha-response').focus()")
                    time.sleep(2)
                    self.driver.execute_script("document.getElementById('g-recaptcha-response').innerHTML='%s'" % captcha_answer)
                    time.sleep(2)
                    nextBtn = self.driver.find_element_by_xpath("//input[@value='Avançar']")
                    nextBtn.click()

Problem: After click the button to submit the form, the page returns an error concerning the "Captcha wrong".

Can someone help me ?

AndreiDrang commented 4 years ago

Hi

  1. Change and hide your anticaptcha_key, cause smb else can use it and spend your money.
  2. Usually if u need solve recaptcha u need make recaptcha textarea visible and then insert captcha-response in it, and only after this steps click button to submit some action(like form send and etc.) U can find example here.
adrianomaia commented 4 years ago

Hello @AndreiDrang, than's for the answer.

I'm inserting the token with this section of the code:

self.driver.execute_script("document.getElementById('g-recaptcha-response').innerHTML='%s'" % captcha_answer)

Work's just fine, but when I submit the form, returns the error "Wrong Captcha". I'm assuming that the token returned is not right..

AndreiDrang commented 4 years ago

Can u give link on page with recaptcha? U can check something: Open page with captcha(manually), than start captcha solving process(with service), get key and try insert it(also manually) and press submit button. Is it working well?

adrianomaia commented 4 years ago

Also not working that way (but that's normal, because the token varies from recaptcha to recaptcha, right?). The link is: (https://www.detran.sp.gov.br/wps/portal/portaldetran/cidadao/veiculos/servicos/pesquisaDebitosRestricoesVeiculos/!ut/p/z1/pZJfb4IwFMU_yx54lN7agmXJsjBFEdHF-b8vpiJqNwFT0e7jD_Y2dU6zm740-Z1z23Mv4miKeCqOci1ymaViW9xn3J4TCgPnBbsAwZCAy2qdMQ5dwmyCJicA8VkBvA19NwQM1Eb8P_oWvVPPvHGz1JMm9l6r0IHb9EEf6r7PqmELN-rgOpR220GHgENu08Mv5cK9_z8D-HX7CeInLc4ncBUoI_4JXMjwG7gW0l_PDBCXi8TUUWKCSaFmW4QRh1rUpgzXyjVz0wVha8RVvIpVrMyDKrZvk-e7_aMBBmitTZ2pD5EKM8oSA2S6yD4NiJTQ21hVlnGuRGqAWCop0qySCCkq9Llwe1KZ2OexutRkk-1zND3xRrNiJhjPKXY8jOvQhVFIoN_v9sYYegDUQgM0axSH6sjTaJeMypqCbL9b22O46rUfvgC-81L0/dz/d5/L2dBISEvZ0FBIS9nQSEh/p0/IZ11_419E11C0M0UL30QQMNV10N0045=CZ6_340S9B1A00JT30A87KV1LA3863=LA0=Ejavax.servlet.include.path_info!QCPpagesQCPdebitosRestricoesTerceirosQCPpesquisaView.xhtml==/#Z11_419E11C0M0UL30QQMNV10N0045)

In order to see the content, you need to put your browser language to PT-BR.

AndreiDrang commented 4 years ago

Also not working that way (but that's normal, because the token varies from recaptcha to recaptcha, right?).

Bad news, u do smth wrong. Your recaptcha solution key must be valid 120sec after receiving (as i remember).

I will check your link bit later.

adrianomaia commented 4 years ago

I don't understand what I did wrong. I follow all the steps, tried with two different api_keys, and nothing seems to work.

The returned token never works. I also attempted another API, same result.

adrianomaia commented 4 years ago

Any news ?

AndreiDrang commented 4 years ago

Hi Nope, try connect to this web site and get white page without any data. Use proxy, change language in browser.

adrianomaia commented 4 years ago

Just change your default language to PT-BR, and the data will appear.

AndreiDrang commented 4 years ago

Okay, I just need to delete all my other languages. But all is working fine. Make textarea visible Get captcha solution Insert solution ---> image Press submit button ---> image

adrianomaia commented 4 years ago

It's giving you the "Wrong Captcha" error: red alert

AndreiDrang commented 4 years ago

Message from the first screen is error from my old try, after this, i receive the second screen with other error(not captcha, as i understand).

Screen Shot 2019-11-26 at 7 46 55 PM
adrianomaia commented 4 years ago

you use my code?

adrianomaia commented 4 years ago

Can you share the code you use ?

AndreiDrang commented 4 years ago

Nope, I just test this method:

Open page with captcha(manually), than start captcha solving process(with service), get key and try insert it(also manually) and press submit button. Is it working well?

If it works - code must work fine if it doesn't work - u need to check your keys/urls and etc.

AndreiDrang commented 4 years ago

To solve recaptcha i use code from example.

adrianomaia commented 4 years ago

Ok, thank you for your time.

adrianomaia commented 4 years ago

To solve recaptcha i use code from example.

  • get captcha solving key

Where is this example ? Sorry, not finding him.

AndreiDrang commented 4 years ago

U can use any: First Second

adrianomaia commented 4 years ago

Did you use NoCaptchaTask or NoCaptchaTaskProxyless ?

AndreiDrang commented 4 years ago

I use Proxyless cause I didn't need any proxy.

adrianomaia commented 4 years ago

Last question, which link did you use do bypass the recapactha ?

https://www.google.com/recaptcha/api2/demo -> this one pointing to the google demo or the one from the website ?

AndreiDrang commented 4 years ago

I use link to page with captcha. For your captcha i use your link.

adrianomaia commented 4 years ago

I understand what I was doing wrong....

I was using the link for the captcha instead I was suppose to use the link for the website containing the captcha.

Thank you for you patience and for this amazing library.