bypass-recaptcha-google-timeoutexception:消息

dly7yett  于 2021-07-13  发布在  Java
关注(0)|答案(0)|浏览(251)

我正在用python和selenium做一个代码来获取信息
我有一个问题要通过recaptcha(图片),下面我将解释我所做的:
我的代码:


# bypass reCAPTCHA google

# Load selenium components

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

from selenium.webdriver.support.ui import Select
from webdriver_manager.chrome import ChromeDriverManager
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import TimeoutException
from selenium.common.exceptions import UnexpectedAlertPresentException
from selenium.webdriver.chrome.options import Options

# based on:

# code source -> https://github.com/ohyicong/recaptcha_v2_solver/blob/master/recaptcha_solver.py#L27

# recaptcha libraries

import speech_recognition as sr
import urllib
import pydub
import time

# system libraries

import os
import sys
import random
import time

def delay ():
    time.sleep(random.randint(2,3))

# initialize the driver

driver = webdriver.Chrome(executable_path="/bin/chromedriver")

# get method to launch the URL

driver.get("http://www.detran.sp.gov.br/wps/portal/portaldetran/cidadao/veiculos/servicos/pesquisaDebitosRestricoesVeiculos")

print('Loading webpage...')

# identifying the link with the help of link text locator

driver.find_element_by_css_selector('img.ico_miniatura').click()

print('Input info placa...')
inputElement = driver.find_element_by_id("viewns_Z11_419E11C0M0UL30QQMNV10N0045_:placa")
inputElement.send_keys('EFP1075')

WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe[name^='a-'][src^='https://www.google.com/recaptcha/api2/anchor?']")))
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "span#recaptcha-anchor"))).click()
driver.switch_to.default_content()

# time.sleep(5)

# HERE START THE PROBLEM:

WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button#recaptcha-audio-button"))).click()

# WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "recaptcha-audio-button"))).click()

# WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, ".rc-audiochallenge-play-button button")))

# get the mp3 audio file

# src = driver.find_element_by_id("audio-source").get_attribute("src")

# print(src)

在这一行,我有一个问题:

WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button#recaptcha-audio-button"))).click()

错误:回溯

Traceback (most recent call last):
  File "scrape.py", line 60, in <module>
    WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button#recaptcha-audio-button"))).click()
  File "/home/andsilva/anaconda3/lib/python3.7/site-packages/selenium/webdriver/support/wait.py", line 80, in until
    raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:

我不明白,也许元素没有找到 button#recaptcha-audio-button 在本图中,显示了下载音频的按钮。在此处输入图像描述
有人知道怎么解决这个问题吗?
提前谢谢
安德烈

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题