Zummy Posted April 3, 2019 Share Posted April 3, 2019 Hey guys, I use Selenium to recover and create accounts but I have a lot of fails where the captcha is solved but upon continuing to the next page, the page just refreshes. Does anyone know what happens here or has any experience in completing this process by the same means? Thanks! Quote Link to comment Share on other sites More sharing options...
Naked Posted April 3, 2019 Share Posted April 3, 2019 2 minutes ago, Zummy said: Hey guys, I use Selenium to recover and create accounts but I have a lot of fails where the captcha is solved but upon continuing to the next page, the page just refreshes. Does anyone know what happens here or has any experience in completing this process by the same means? Thanks! 1) Make sure your proxies aren't blocking the recaptcha from loading (Inspect and look at errors) 2) Use this to inject the captcha response: JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript("document.getElementById(\"g-recaptcha-response\").innerHTML=\""+response+"\";"); 3) make sure you're submitting the form and not clicking it if(isElementPresent(driver, By.id("password-recovery-form"))){ driver.findElement(By.id("password-recovery-form")).submit(); } Quote Link to comment Share on other sites More sharing options...
Zummy Posted April 3, 2019 Author Share Posted April 3, 2019 8 minutes ago, Naked said: 1) Make sure your proxies aren't blocking the recaptcha from loading (Inspect and look at errors) 2) Use this to inject the captcha response: 3) make sure you're submitting the form and not clicking it Thanks for the reply! I'm using the same technique: RemoteWebDriver r = (RemoteWebDriver) driver; String setResponseToken = "document.getElementById('g-recaptcha-response').innerHTML='" + CAPTCHA + "'"; r.executeScript(setResponseToken); r.executeScript("onSubmit()"); What anti captcha service do you use? Quote Link to comment Share on other sites More sharing options...
Naked Posted April 3, 2019 Share Posted April 3, 2019 1 minute ago, Zummy said: Thanks for the reply! I'm using the same technique: RemoteWebDriver r = (RemoteWebDriver) driver; String setResponseToken = "document.getElementById('g-recaptcha-response').innerHTML='" + CAPTCHA + "'"; r.executeScript(setResponseToken); r.executeScript("onSubmit()"); What anti captcha service do you use? anticaptcha Did you verify the captcha is loading? Quote Link to comment Share on other sites More sharing options...
Zummy Posted April 3, 2019 Author Share Posted April 3, 2019 1 minute ago, Naked said: anticaptcha Did you verify the captcha is loading? I'm also using anticaptcha, what's your fail-rate? No I don't verify if it has been loaded, can I check for certain HTML elements to verify if it's loaded? I don't think it's proxy related, sometimes it does and sometimes it doesn't complete the captcha with the same proxy. Quote Link to comment Share on other sites More sharing options...
Naked Posted April 3, 2019 Share Posted April 3, 2019 14 minutes ago, Zummy said: I'm also using anticaptcha, what's your fail-rate? No I don't verify if it has been loaded, can I check for certain HTML elements to verify if it's loaded? I don't think it's proxy related, sometimes it does and sometimes it doesn't complete the captcha with the same proxy. Failure rate is low (not sure on actual number). Should always check if it's loaded. You can do this by looking for the element. Google captcha likes to misbehave when using a SOCKS connection Quote Link to comment Share on other sites More sharing options...
Impensus Posted April 3, 2019 Share Posted April 3, 2019 49 minutes ago, Naked said: Failure rate is low (not sure on actual number). Should always check if it's loaded. You can do this by looking for the element. Google captcha likes to misbehave when using a SOCKS connection how come you use anti-captcha over 2captcha? Is the price point different? Quote Link to comment Share on other sites More sharing options...
Naked Posted April 3, 2019 Share Posted April 3, 2019 6 minutes ago, Impensus said: how come you use anti-captcha over 2captcha? Is the price point different? No reason tbh Quote Link to comment Share on other sites More sharing options...
Chris Posted April 3, 2019 Share Posted April 3, 2019 # Login form handler runescape.com def runescape_login(driver, username, password): # On runescape account login screen print("On the login page") username_field = driver.find_element_by_id("login-username") password_field = driver.find_element_by_id("login-password") print("Placing log in credentials") if username not in username_field.text: username_field.clear() print("Filling username data") username_field.send_keys(username) print("Filling password data") password_field.send_keys(password) if runescape_site_key in driver.page_source: # Generates the captcha token and executes javascript print("RecaptchaV2") captcha_id = get_captcha_id(runescape_login_url, runescape_site_key) captcha_token = get_captcha_token(captcha_id) driver.execute_script("document.getElementById('g-recaptcha-response').innerHTML = '" + captcha_token + "'; onSubmit();") time.sleep(3) pass else: print("Clicking the login button") driver.find_element_by_id("du-login-submit").click() 1 Quote Link to comment Share on other sites More sharing options...
Impensus Posted April 3, 2019 Share Posted April 3, 2019 2 hours ago, Zummy said: Hey guys, I use Selenium to recover and create accounts but I have a lot of fails where the captcha is solved but upon continuing to the next page, the page just refreshes. Does anyone know what happens here or has any experience in completing this process by the same means? Thanks! Also just a side note, I’d recommend ditching selenium and running the script over post/get requests instead as it will be far more lightweight. Quote Link to comment Share on other sites More sharing options...
Zummy Posted April 4, 2019 Author Share Posted April 4, 2019 Thanks for all the replies guys! If I understand this correctly, as long as the sitekey is present in the page source, recaptcha is loaded? 9 hours ago, Impensus said: Also just a side note, I’d recommend ditching selenium and running the script over post/get requests instead as it will be far more lightweight. I did that in the beginning until they changed to invisible captcha's. I don't know much about HTTP requests and calling functions while doing so (onSubmit()), so I changed it all to Selenium. Quote Link to comment Share on other sites More sharing options...
flakeybanana Posted April 4, 2019 Share Posted April 4, 2019 i use anticaptcha and have the same problem, basically anticapcha just shits the bed and gives the wrong value. Quote Link to comment Share on other sites More sharing options...
Impensus Posted April 4, 2019 Share Posted April 4, 2019 7 hours ago, Zummy said: Thanks for all the replies guys! If I understand this correctly, as long as the sitekey is present in the page source, recaptcha is loaded? I did that in the beginning until they changed to invisible captcha's. I don't know much about HTTP requests and calling functions while doing so (onSubmit()), so I changed it all to Selenium. Basically how 2captcha works(not sure if anti captcha is the same) is that you send a request for a url with their site key. 2captcha use this to generate a captcha on their end and send you the ID of this captcha. You send a request for it to be solved and given the token back. To answer your question, every site that has recaptcha must have a site key and this must be present somewhere in the source. and I’d say it’s worth giving http requests a look. I had no clue about them either until I tried it and a bit of trial and error got it working. Quote Link to comment Share on other sites More sharing options...
Its Not Okay Posted April 9, 2019 Share Posted April 9, 2019 On 4/3/2019 at 11:34 PM, Chris said: # Login form handler runescape.com def runescape_login(driver, username, password): # On runescape account login screen print("On the login page") username_field = driver.find_element_by_id("login-username") password_field = driver.find_element_by_id("login-password") print("Placing log in credentials") if username not in username_field.text: username_field.clear() print("Filling username data") username_field.send_keys(username) print("Filling password data") password_field.send_keys(password) if runescape_site_key in driver.page_source: # Generates the captcha token and executes javascript print("RecaptchaV2") captcha_id = get_captcha_id(runescape_login_url, runescape_site_key) captcha_token = get_captcha_token(captcha_id) driver.execute_script("document.getElementById('g-recaptcha-response').innerHTML = '" + captcha_token + "'; onSubmit();") time.sleep(3) pass else: print("Clicking the login button") driver.find_element_by_id("du-login-submit").click() Thank you so much! Was trying to get mine to work for the past few days, I realized my mistake was with the javascript, I didn't add onSubmit(); after I I fill everything else in! 1 Quote Link to comment Share on other sites More sharing options...