python - 有没有办法从网站上点击 recaptcha 元素
问题描述
所以我试图通过硒解决验证码。首先,我尝试单击此网站https://patrickhlauke.github.io/recaptcha/上的验证码。我尝试了没有成功的 xpath 和 ID 方法。有人可以帮我吗?这是我要单击的图片, 这也是我所写的。任何帮助,将不胜感激。
from selenium import webdriver
import keyboard
import time
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.select import Select
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)
driver.get("https://patrickhlauke.github.io/recaptcha/")
time.sleep(3)
driver.find_element_by_xpath('//*[@id="recaptcha-anchor"]')
解决方案
<iframe src="https://www.google.com/recaptcha/api2/anchor?ar=1&k=6Ld2sf4SAAAAAKSgzs0Q13IZhY02Pyo31S2jgOB5&co=aHR0cHM6Ly9wYXRyaWNraGxhdWtlLmdpdGh1Yi5pbzo0NDM.&hl=en&v=5mNs27FP3uLBP3KBPib88r1g&size=normal&cb=ufdnmqmcxiqv" width="304" height="78" role="presentation" name="a-y2973t5aots" frameborder="0" scrolling="no" sandbox="allow-forms allow-popups allow-same-origin allow-scripts allow-top-navigation allow-modals allow-popups-to-escape-sandbox"></iframe>
您的元素在 iframe 切换到它。现在你的 xpath 应该可以工作了。
driver.switch_to.frame(0)
推荐阅读
- angular - 如何导入特定版本的 jquery 和 jquery 插件仅特定于 angular5 中的某个组件?
- mysql - 如何在数据库上存储带有订购项目的清单
- hadoop - Hadoop 问题,尝试在 hadoop 上运行基本 WordCount MapReduce
- node.js - Node-red 随机重启
- android - 如何让用户在 google session firebase 中退出?
- sql-server - SQL Server 存储过程接受可选参数
- android - 如何在服务内运行 onLocationChanged
- tizen - 像 Green Hill Software 的 INTEGRITY RTOS 这样的 RTOS 如何与汽车级 linux 集成?
- c++ - C++ 未在 Atom 中编译
- redis - 我在列表中的 ElastiCache 上的 Redis 中获取损坏的数据