验证码识别是常见的反爬手段之一,这次做了个滑动验证码的识别,在这个网站上做检测
https://promotion.aliyun.com/ntms/act/captchaIntroAndDemo.htmlhttps://promotion.aliyun.com/ntms/act/captchaIntroAndDemo.html
既然要滑动滑块那么就需要使用selenium模拟浏览了,selenium被很多网站进行了屏蔽,用selenium驱动浏览器时,在控制台输入window.navigator.webdriver时值为True.而非selenium环境下,它的值为undefined。
本文采用在驱动浏览器的时候,选用开发者模式驱动浏览器,这样就不会被网站识别为selenium驱动了。在控制台输入window.navigator.webdriver,结果如上,所以在开发者模式驱动浏览器可以避免被识别。
在模拟轨迹滑动的时候,选择先加速后减速的方式滑动。附上代码。`from selenium import webdriver
import time
from selenium.webdriver import ChromeOptions
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver import ActionChains
##选用开发者模式,创建一个浏览器对象
option = ChromeOptions()
option.add_experimental_option(‘excludeSwitches’,[‘enable-automation’])
br
使用selenium识别滑动验证码(一)
最新推荐文章于 2024-04-30 13:41:44 发布