【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()
相关推荐
--运维实习生--33 分钟前
自动化运维之ansible
运维·自动化·ansible
励志不掉头发的内向程序员1 小时前
从零开始的python学习——文件
开发语言·python·学习
THMAIL1 小时前
量化基金从小白到大师 - 金融数据获取大全:从免费API到Tick级数据实战指南
人工智能·python·深度学习·算法·机器学习·金融·kafka
泛联新安1 小时前
如何根据项目需求选择合适的软件测试工具?iUnit智能单元测试平台提供专业化解决方案
c++·测试工具·单元测试
代码欢乐豆2 小时前
scikit-learn零基础配置(含python、anaconda)
python·机器学习·scikit-learn
Java水解2 小时前
Python数据库操作:SQLAlchemy ORM指南
python
悠哉悠哉愿意2 小时前
【数学建模学习笔记】无监督聚类模型:分层聚类
笔记·python·学习·数学建模
eleqi2 小时前
Python+DRVT 从外部调用 Revit:批量创建门
python·系统集成·bim·revit·drvt·自动生产流水线
先做个垃圾出来………2 小时前
PyTorch 模型文件介绍
人工智能·pytorch·python
浅醉樱花雨2 小时前
vosk语音识别实战
人工智能·python·语音识别·asr·vosk