我正在使用2captcha API来解决Recaptcha V2 Invisible的自动浏览。我已经咨询并遵循了2captcha主页、youtube和StackOverflow社区的说明。现在运行后,我得到了响应并显示了结果,但无法验证验证码。有人能帮我找到我需要做什么来提交后,解决了验证码放置?
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.proxy import *
from time import sleep
import time
import openpyxl
import requests
import pandas as pd
from solveRecaptcha import solveRecaptcha
# Load the Excel file
df = pd.read_excel('file.xlsx')
# Loop through the rows of the DataFrame
for index, row in df.iterrows():
# Print the current row
print('Current row: /n', row)
# Do your processing here
username = row['Name']
password = row['Pass']
# Create a new instance of the webdriver with the updated capabilities
# Use selenium to log in with the username and password
driver = webdriver.Chrome('./chromedriver')
driver.get("https://www.reddit.com/account/register/")
driver.find_element(By.XPATH, "/html/body/div/main/div[1]/div/div[2]/form/fieldset[2]/button").click()
sleep(3)
driver.find_element(By.XPATH, "/html/body/div/main/div[2]/div/div/div[2]/div[1]/form/fieldset[1]/input[2]").send_keys(username)
driver.find_element(By.CSS_SELECTOR, "input#regPassword").send_keys(password)
sleep(10)
result = solveRecaptcha(
"6LeTnxkTAAAAAN9QEuDZRpn90WwKk_R1TRW_g-JC",
"https://www.reddit.com/account/register/",
)
print(result)
sleep(10)
code = result('code')
WebDriverWait(driver, 10).until(
EC.presence_of_all_elements_located((By.ID, 'g-recaptcha-response'))
)
driver.execute_script(
"document.getElementByID('g-recaptcha-response').innerHTML = " + "'" + code + "'")
driver.find_element(By.ID, "recaptcha-verify-button").click()
sleep(77)
1条答案
按热度按时间r3i60tvu1#
各位,在得到@约翰戈登的帮助后,我知道我的错误了。谢谢你,约翰!