【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()
相关推荐
孟健9 小时前
Karpathy 用 200 行纯 Python 从零实现 GPT:代码逐行解析
python
码路飞11 小时前
写了个 AI 聊天页面,被 5 种流式格式折腾了一整天 😭
javascript·python
曲幽13 小时前
FastAPI压力测试实战:Locust模拟真实用户并发及优化建议
python·fastapi·web·locust·asyncio·test·uvicorn·workers
敏编程18 小时前
一天一个Python库:jsonschema - JSON 数据验证利器
python
前端付豪18 小时前
LangChain记忆:通过Memory记住上次的对话细节
人工智能·python·langchain
databook18 小时前
ManimCE v0.20.1 发布:LaTeX 渲染修复与动画稳定性提升
python·动效
花酒锄作田1 天前
使用 pkgutil 实现动态插件系统
python
前端付豪1 天前
LangChain链 写一篇完美推文?用SequencialChain链接不同的组件
人工智能·python·langchain
曲幽1 天前
FastAPI实战:打造本地文生图接口,ollama+diffusers让AI绘画更听话
python·fastapi·web·cors·diffusers·lcm·ollama·dreamshaper8·txt2img
老赵全栈实战1 天前
Pydantic配置管理最佳实践(一)
python