有没有办法从网站上点击 recaptcha 元素

Is there a way to click on a recaptcha element from a site

所以我正在尝试通过 selenium 解决验证码问题。首先我尝试点击这个网站上的验证码 https://patrickhlauke.github.io/recaptcha/. I try xpath and ID method which hasn't had any success. Could someone please help me out here. Here is a picture of what I am trying to click 这也是我写的。任何帮助将不胜感激。

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&amp;k=6Ld2sf4SAAAAAKSgzs0Q13IZhY02Pyo31S2jgOB5&amp;co=aHR0cHM6Ly9wYXRyaWNraGxhdWtlLmdpdGh1Yi5pbzo0NDM.&amp;hl=en&amp;v=5mNs27FP3uLBP3KBPib88r1g&amp;size=normal&amp;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)