python+selenium+chrome 做滑动验证码 会被浏览器检测到使用的自动软件导致滑动验证失败

2021/9/20 12:04:49

本文主要是介绍python+selenium+chrome 做滑动验证码 会被浏览器检测到使用的自动软件导致滑动验证失败,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

python+selenium+chrome 做滑动验证码 会被浏览器检测到使用的自动软件导致滑动验证失败

解决方法:代码中添加:

import time
from selenium import webdriver
from selenium.webdriver import ActionChains
options = webdriver.ChromeOptions()
options.add_argument('--disable-blink-features=AutomationControlled')    #重点代码:去掉了webdriver痕迹
brow = webdriver.Chrome(chrome_options=options)
brow.get(url)
print("滑块")
action_chains = ActionChains(brow)
time.sleep(3)
print("h1")
slider1 = brow.find_element_by_xpath('//*[@id="nc_1_n1z"]')   #定位滑块
action_chains.drag_and_drop_by_offset(slider1, 280, 0).perform()  #开始滑块验证

根据情况通过options.add_argument()来添加ua和ip代理或其他的请求头信息



这篇关于python+selenium+chrome 做滑动验证码 会被浏览器检测到使用的自动软件导致滑动验证失败的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程