简体   繁体   English

有没有办法通过使用 selenium python 绕过 Hcaptcha

[英]Is there any way to bypass Hcaptcha by using selenium python

有没有办法通过使用 selenium python 绕过 Hcaptcha,我尝试了 2captcha( https://2captcha.com/ ) API,但它不起作用

bypassing is sadly not an option.遗憾的是,绕过不是一种选择。 What you want to do is to retrieve a solution from sites like 2captcha, while having the solution you need to find the element with the name "h-captcha-response" and edit it so it is visible, after that you need to write the solution of your captcha and submit the form.您想要做的是从 2captcha 之类的网站检索解决方案,同时拥有您需要找到名称为“h-captcha-response”的元素并对其进行编辑以使其可见的解决方案,之后您需要编写您的验证码的解决方案并提交表格。

driver.execute_script("document.getElementByName('h-recaptcha-response').style = 'width: 250px; height: 40px; border: 1px solid rgb(193, 193, 193); margin: 10px 25px; padding: 0px;';")
    
driver.find_element(By.XPATH,'//*[@id="h-recaptcha-response"]').send_keys(recaptcha_solution)

this is a code I had laying around from another site, but it should make the h-captcha-response show up in your case as well, you need to find the XPATH of the element afterwards and write your own response and click the submit button.这是我从另一个站点放置的代码,但它也应该使 h-captcha-response 出现在您的情况下,您需要在之后找到元素的 XPATH 并编写您自己的响应并单击提交按钮.

If the code doesn't work try to find the h-recaptcha-response in the HTML and see if it is on the name or the ID of the element, this example assumes it has this name but it is also possible that it is on the ID, in that case you should use如果代码不起作用,请尝试在 HTML 中查找 h-recaptcha-response 并查看它是否在元素的名称或 ID 上,此示例假定它具有此名称,但也可能在ID,在这种情况下你应该使用

driver.execute_script("document.getElementById('h-recaptcha-response').style = 'width: 250px; height: 40px; border: 1px solid rgb(193, 193, 193); margin: 10px 25px; padding: 0px;';")

While automating Captcha is not the best practice, there are three efficient ways of handling Captcha in Selenium:虽然自动化验证码不是最佳实践,但在 Selenium 中处理验证码有三种有效的方法:

  1. By disabling the Captcha in the testing environment通过在测试环境中禁用验证码
  2. Adding a hook to click the Captcha checkbox添加一个钩子以单击 Captcha 复选框
  3. By adding a delay to the Webdriver and manually solve Captcha while testing通过向 Webdriver 添加延迟并在测试时手动解决 Captcha

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 有没有办法绕过 Selenium webdriver 中的 Google 代理块? - Is there any way to bypass Google proxy block in Selenium webdriver? 有没有办法绕过 selenium 和 python 显式等待的 500 毫秒延迟 - Is there a way to bypass the 500ms delay on explicit waits with selenium and python 如何在 Python 中使用 Selenium 绕过人工验证“按住”? - How to bypass human verification 'press and hold' using Selenium in Python? 无法在 selenium (python) 中使用 .scrollTo() 和 .scrollIntoView() 滚动网页还有其他方法吗? - Unable to scroll webpage using .scrollTo() and .scrollIntoView() in selenium (python) any other way to do it? 在使用.clear()或.send_keys()后禁用按钮时,如何使用Python Selenium单击(绕过)提交按钮? - How can I click (bypass) a submit button using Python Selenium, when the button gets disabled after using .clear() or .send_keys()? 使用Selenium和XPath跳过/跳过包含无文本的单元格的表行 - Bypass/skip table rows that contains cell with no text using selenium and xpath 绕过cookiewall硒 - bypass cookiewall selenium selenium:绕过访问被拒绝 - selenium: bypass access denied 有没有办法使用 selenium webdriver (python) 捕获样式数据? - Is there a way to capture style data using selenium webdriver (python)? 有没有办法在 PYTHON 中使用 selenium 向上滚动网页中的特定 div 元素? - Is there a way to scroll up a particular div element in a webpage using selenium with PYTHON?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM