微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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代理或其他的请求头信息

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐