0

我正在尝试使用 selenium 在 Twitter 上注册并使用 2captcha API 来解决验证码,但是由于某种原因,当单击继续时页面刷新并且没有继续

        captchaInput = twitter_driver.find_element_by_id('g-recaptcha-response')
        print("Text area set to visible")
        twitter_driver.execute_script("arguments[0].setAttribute('style','display:visible;');", captchaInput)
        time.sleep(5)
        print("Entering captcha token")
        captchaInput.send_keys(captcha_token)
        time.sleep(5)
        button_click = "javascript:document.getElementById('continue_button').click();"
        twitter_driver.execute_script(button_click)
4

2 回答 2

0

如果您使用 Python 编写代码,请尝试这样做

wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, '#your selector'))).click()

写得很好https://selenium-python.readthedocs.io/locating-elements.html#:~:text=content%20%3D%20driver.find_element_by_css_selector(%27p.content%27)

如果您不尝试更详细地描述错误

于 2021-09-20T14:34:52.140 回答
0

所以回答我自己的问题只是为了记录,推特使用回调验证码,所以即使你通过 JS 点击提交按钮,未解决的验证码也会重新加载页面

这个要点帮助我解决了验证码问题

于 2021-10-31T11:05:39.803 回答