Open B1NT0N opened 6 months ago
Sounds like a good idea! Implementing a CAPTCHA solving API service can definitely improve login consistency. And also your 2Captcha API key would be very helpful for development.
I've manage to get the data-sitekey
attribute, but I'm having trouble sending the TOKEN
to the input field.
Here is a snippet of the code:
div_selector = 'div.my-10'
page.wait_for_selector(div_selector)
# Get the div element
div_element = page.query_selector(div_selector)
# Get the iframe inside the div
iframe_selector = 'iframe'
iframe_element = div_element.query_selector(iframe_selector)
pattern = r'/0x([A-Za-z0-9_-]+)/'
# Use re.search to find the pattern in the URL
match = re.search(pattern, iframe_url)
extracted_info = match.group(1)
Here is the 2captcha Cloudflare Turnstile demo for context, Please DM me for the API key
I might think they used the Cloudflare Challenge page. Which is difficult to solve. Extracting the data-sitekey might not work here.
I might think they used the Cloudflare Challenge page. Which is difficult to solve. Extracting the data-sitekey might not work here.
I'm not seeing the Cloudflare Challenge page when accesing the website though, just what I belive to be the normal Cloudflare Turnstile challenge. But since I'm new to this I may be wrong
This is what I'm talking about:
I've manage to get the
data-sitekey
attribute, but I'm having trouble sending theTOKEN
to the input field. Here is a snippet of the code:div_selector = 'div.my-10' page.wait_for_selector(div_selector) # Get the div element div_element = page.query_selector(div_selector) # Get the iframe inside the div iframe_selector = 'iframe' iframe_element = div_element.query_selector(iframe_selector) pattern = r'/0x([A-Za-z0-9_-]+)/' # Use re.search to find the pattern in the URL match = re.search(pattern, iframe_url) extracted_info = match.group(1)
Here is the 2captcha Cloudflare Turnstile demo for context, Please DM me for the API key
Thanks for sharing! I will check it over the weekends and can you share the API keys over the email, if that's ok?
I've managed to verify the Captcha with TwoCaptcha, get the token in result and fill the value in the input but it is not getting verified... It is still showing the checkbox "Verify you are a human"... I don't know why because when I use my normal browser (Chrome or Safari), it is automatically verified. Any update on that process @ranjan-mohanty? :)
`def check_captcha(self, page: Page) -> None: """ Performs captcha verification.
Args:
page (playwright.sync_api.Page): The Playwright page object used for browser interaction.
"""
div_selector = 'div.my-10'
page.wait_for_selector(div_selector)
# Get the div element
div_element = page.query_selector(div_selector)
if not div_element:
logging.error(f"Div element with selector '{div_selector}' not found.")
return None
# Get the iframe inside the div
iframe_selector = 'iframe'
iframe_element = div_element.query_selector(iframe_selector)
if not iframe_element:
logging.error(f"Iframe element with selector '{iframe_selector}' not found.")
return None
# Get the iframe URL
iframe_url = iframe_element.get_attribute('src')
if not iframe_url:
logging.error("Iframe URL not found.")
return None
# Define the pattern to extract information from the URL
pattern = r'/0x([A-Za-z0-9_-]+)/'
# Use re.search to find the pattern in the URL
match = re.search(pattern, iframe_url)
if match:
extracted_info = match.group(1)
logging.debug(f"Extracted info: {extracted_info}")
print(f"Extracted info: {extracted_info}")
print(f"Page: {page.url}")
result = solver.turnstile(sitekey=f"0x{extracted_info}", url=page.url)
print(f"Result: {result}")
if result and 'code' in result:
captcha_token = result['code']
page.evaluate(f'document.getElementsByName("cf-turnstile-response")[0].value="{captcha_token}";')
return captcha_token
else:
logging.error("CAPTCHA solving failed or no code returned.")
return None
else:
logging.error("Pattern not found in the iframe URL.")
return None`
`from twocaptcha import TwoCaptcha
solver = TwoCaptcha('API_KEY')`
@PogProp I'm facing the same issue. Were you able to solve this?
No, still having this issue…
Is your feature request related to a problem? Please describe. Logging in became unreliable after some time, so I suggest an implementation of a captcha solving method.
Describe the solution you'd like We could use a captcha solving API service to do so and improve login in consistency.
I'm willing to provide my 2captcha API key to help development.