【Python selenium过极验滑块】用自动化selenium 操作GEETEST极验滑块,简单粗暴

文章日期:2024.07.24

使用工具:Python

文章类型:自动化过极验滑块

文章全程已做去敏处理!!! 【需要做的可联系我】

AES解密处理(直接解密即可)(crypto-js.js 标准算法):​​​​​​在线AES加解密工具

**【点赞 收藏 关注 】**仅供学习,仅供学习。

注意:要用Google浏览器和Google驱动,可以在这里下载Google浏览器 和 浏览器驱动下载 教程分享
今天用Python 的 selenium模块,自动化过极验滑块验证,很好用哦

先看效果,觉得效果不好就滑走吧

看完了吗,代码拿走吧,注释写的很明白,不懂可以留言哦
python 复制代码
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
import time
import re
import requests
# 安装库 pip install ddddocr
import ddddocr
# 运行脚本实列化一次即可,不要重复实列化,会浪费时间
det = ddddocr.DdddOcr(det=False, ocr=False)

# 配置 Chrome 浏览器
chrome_options = webdriver.ChromeOptions()
chrome_options.binary_location = "chrome/chrome.exe"  # 指定 Chrome 浏览器的路径
chrome_options.add_argument("--disable-infobars")   #  禁用浏览器中的"信息栏",避免干扰测试。
# 启动浏览器
driver = webdriver.Chrome(options=chrome_options)

# 打开 Google
driver.get("http://gt4.geetest.com/")

print('点击开始验证')
# 点击验证
driver.find_element(By.XPATH,r'/html/body/div/div/div[2]/div[2]/form/div[3]/div[3]/div[1]/div[1]').click()
print('等待加载')
time.sleep(4)
data = driver.page_source
# 背景图
beijnigtu = re.findall('class="geetest_bg_.*?url\("(.*?)"\);',data)
# 小拼图
xiaopintu = re.findall('class="geetest_slice_bg_.*?url\("(.*?)"\);',data)
print('成功获取背景图和小拼图的链接')
# 请求背景图
requests_beijnigtu = requests.get(beijnigtu[0]).content
# 小拼图
requests_xiaopintu = requests.get(xiaopintu[0]).content
print('背景图和小拼图已请求成功!!!')
# 开始识别滑块距离
res1 = det.slide_match(requests_beijnigtu, requests_xiaopintu, simple_target=True)['target'][0]
print(f'识别出距离:{res1}')
# 定位滑块的滑动按钮
element = driver.find_element(By.XPATH,r'/html/body/div/div/div[2]/div[2]/form/div[3]/div[3]/div[1]/div[4]/div[1]/div[2]/div/div/div[2]/div/div[3]')
print('滑动按钮已定位')
# 点击并抓住标签
ActionChains(driver).click_and_hold(element).perform()
print('开始滑动')
# 开始滑动
ActionChains(driver).move_by_offset(xoffset=res1-1, yoffset=0).perform()  # 向右滑动114像素(向左是负数)
# 松开按钮
ActionChains(driver).release().perform()
print('完成')
print('等待执行其他操作!!!')
time.sleep(1000)
# 关闭浏览器
driver.quit()
相关推荐
Eiceblue14 分钟前
Python 复制Excel 中的行、列、单元格
开发语言·python·excel
NLP工程化29 分钟前
对 Python 中 GIL 的理解
python·gil
极客代码39 分钟前
OpenCV Python 深度指南
开发语言·人工智能·python·opencv·计算机视觉
liO_Oil41 分钟前
(2024.9.19)在Python的虚拟环境中安装GDAL
开发语言·python·gdal安装
奈斯。zs1 小时前
yjs08——矩阵、数组的运算
人工智能·python·线性代数·矩阵·numpy
Melody20501 小时前
tensorflow-dataset 内网下载 指定目录
人工智能·python·tensorflow
学步_技术1 小时前
Python编码系列—Python抽象工厂模式:构建复杂对象家族的蓝图
开发语言·python·抽象工厂模式
Narutolxy2 小时前
Python 单元测试:深入理解与实战应用20240919
python·单元测试·log4j
Amo Xiang2 小时前
2024 Python3.10 系统入门+进阶(十五):文件及目录操作
开发语言·python
liangbm32 小时前
数学建模笔记——动态规划
笔记·python·算法·数学建模·动态规划·背包问题·优化问题