gpt4 book ai didi

python - 改进 reCaptcha 2.0 解决自动化脚本(Selenium)

转载 作者:行者123 更新时间:2023-12-04 12:49:39 26 4
gpt4 key购买 nike

我用 selenium 代码写了一个 python 来解决 new behaviour captcha .但是缺乏完全模仿用户行为的东西:代码可以定位并点击验证码,但在那之后谷歌设置了额外的图片检查enter image description here

这不容易自动化。如何改进代码以在没有图片检查的情况下立即解决验证码(让谷歌没有机器人存在的迹象)?

Python代码

from time import sleep
from random import uniform
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions as EC

# to imitate hovering
def hover(element):
hov = ActionChains(driver).move_to_element(element)
hov.perform()
# optional: adding www.hola.org proxy profile to FF (extention is installed on FF, Win 8)
ffprofile = webdriver.FirefoxProfile()
hola_file = '/Users/Igor/AppData/Roaming/Mozilla/Firefox/Profiles/7kcqxxyd.default-1429005850374/extensions/hola/hola_firefox_ext_1.9.354_www.xpi'
ffprofile.add_extension(hola_file)
# end of the optional part

driver = webdriver.Firefox(ffprofile)
url='http://tarex.ru/testdir/recaptcha/recaptcha.php'

# open new tab, also optional
driver.find_element_by_tag_name('body').send_keys(Keys.COMMAND + 't')
driver.get(url)

recaptchaFrame = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.TAG_NAME ,'iframe'))
)
frameName = recaptchaFrame.get_attribute('name')

# move the driver to the iFrame...
driver.switch_to_frame(frameName)

# ************* locate CheckBox **************
CheckBox = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID ,"recaptcha-anchor"))
)

# ************* hover CheckBox ***************
rand=uniform(1.0, 1.5)
print('\n\r explicit wait for ', rand , ' seconds...')
sleep(rand)
hover(CheckBox)

# ************* click CheckBox ***************
rand=uniform(0.5, 0.7)
print('\n\r explicit wait for ', rand , 'seconds...')
sleep(rand)
# making click on CheckBox...
clickReturn= CheckBox.click()
print('\n\r after click on CheckBox... \n\r CheckBox click result: ' , clickReturn)

最佳答案

你不能那样做,我认为当从同一个 IP 完成太多请求时会使用图像障碍,所以你不能绕过它,你可以做的是使用代理

关于python - 改进 reCaptcha 2.0 解决自动化脚本(Selenium),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32249190/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com