Pretty much new with captcha and Python requests. The captcha documentation says to copy the value of data-sitekey
parameter.
Here was my attempt, using Selenium to open the url and using Python requests
to get a response.
mainurl = 'https://imagetyperz.xyz/automation/recaptcha-v2.html'
driver.get(mainurl)
data_sitekey_class = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CLASS_NAME, "g-recaptcha"))).get_attribute("data-sitekey")
print(data_sitekey_class)
src_css_selector = driver.find_element_by_css_selector("iframe[role='presentation']").get_attribute("src")
print(src_css_selector)
keygoogle = src_css_selector[52:92]
print('Site Key = ', keygoogle)
data_post = {'key': data_sitekey_class, 'method': 'userrecaptcha', 'googlekey': keygoogle, "pageurl": mainurl}
response = requests.post(url = 'https://2captcha.com/in.php', data = data_post )
print(response)
print(response.text)
I am getting 200
as response:
6LdXeIYUAAAAAFmFKJ6Cl3zo4epRZ0LDdOrYsvRY
https://www.google.com/recaptcha/api2/anchor?ar=1&k=6LdXeIYUAAAAAFmFKJ6Cl3zo4epRZ0LDdOrYsvRY&co=aHR0cHM6Ly9pbWFnZXR5cGVyei54eXo6NDQz&hl=en&v=vJuUWXolyYJx1oqUVmpPuryQ&size=normal&cb=r14cgu7t25ul
Site Key = 6LdXeIYUAAAAAFmFKJ6Cl3zo4epRZ0LDdOrYsvRY
<Response [200]>
ERROR_WRONG_USER_KEY
which is due to:
ERROR_WRONG_USER_KEY
Further, Error section mentions:
Error code: ERROR_WRONG_USER_KEY
Description: You've provided key parameter value in incorrect format, it should contain 32 symbols.
Action: Stop sending requests. Check your API key.
Finally, Solving Captchas section mentions:
Get your API key from your account settings page. Each user is given a unique authentication token, we call it API key. It's a 32-characters string that looks like:
1abc234de56fab7c89012d34e56fa7b8
Where as the data-sitekey
I am seeing is:
6LdXeIYUAAAAAFmFKJ6Cl3zo4epRZ0LDdOrYsvRY
which is 41 bit.
Where am I going wrong?