Код: Выделить всё
Error solving CAPTCHA: 没有找到元素。 method: ele() args: {'locator': '#audio-source', 'index': 1, 'timeout': 10}
Вот соответствующая часть моего кода:
Код: Выделить всё
import os
import urllib.request
import random
import time
import pydub
import speech_recognition as sr
from DrissionPage import ChromiumPage
class RecaptchaSolver:
def __init__(self, driver):
self.driver = driver
def solveCaptcha(self):
# Locate the iframe containing the reCAPTCHA
iframe_inner = self.driver("@title=reCAPTCHA")
time.sleep(0.1)
# Click the reCAPTCHA checkbox
iframe_inner('.rc-anchor-content', timeout=1).click()
# Click on the audio button
iframe = self.driver("xpath://iframe[contains(@title, 'recaptcha')]")
iframe('#recaptcha-audio-button', timeout=1).click()
time.sleep(1) # Wait for the audio challenge to load
# Try to find the audio source element
self.driver.wait.ele_displayed('#audio-source', timeout=10)
src = iframe('#audio-source').attrs['src']
# Download the audio and process it
temp_dir = os.getenv("TEMP") if os.name == "nt" else "/tmp/"
path_to_mp3 = os.path.join(temp_dir, f"{random.randint(1, 1000)}.mp3")
urllib.request.urlretrieve(src, path_to_mp3)
# More code for audio processing follows...
Увеличить время ожидания для поиска #audio-source.
Проверить успешность нажатия кнопки аудио.
Добавление явного ждет и откладывает.
Несмотря на эти усилия, элемент до сих пор не найден. Кто-нибудь сталкивался с подобной проблемой при автоматизации аудиозапросов reCAPTCHA? Как я могу убедиться, что элемент #audio-source расположен правильно?
Дополнительная информация:
Я использую DrissionPage с браузером на базе Chromium.
Кнопка аудио нажимается успешно, но элемент источника звука, похоже, так и не появляется.
Страница, с которой я работаю, — это страница входа в Activision.
Подробнее здесь: https://stackoverflow.com/questions/790 ... issionpage