爬虫(滑块验证的破解)

基于滑块的验证破解 ------ Selenium

1.可分为三个核心步骤
  • 获取验证码图片
  • 识别图片,计算轨迹距离
  • 寻找滑块,控制滑动

打开网址:https://www.geetest.com/adaptive-captcha-demo

2.获取验证图片
python 复制代码
import re
import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait

service = Service('driver/chromedriver.exe')
driver = webdriver.Chrome(service=service)

# 1.打开首页
driver.get('https://www.geetest.com/adaptive-captcha-demo')

# 2.点击【滑动图片验证】
tag = WebDriverWait(driver, 30, 0.5).until(lambda dv: dv.find_element(
    By.XPATH,
    '//*[@id="gt-showZh-mobile"]/div/section/div/div[2]/div[1]/div[2]/div[3]/div[3]',
))
tag.click()

# 3.点击开始验证
tag = WebDriverWait(driver, 30, 0.5).until(lambda dv: dv.find_element(
    By.CLASS_NAME,
    'geetest_btn_click',
))
tag.click()

# 4.获取背景图片 - 使用了闭包
def fetch_image_func(class_name):
    def inner(dv):
        tag_object = dv.find_element(
            By.CLASS_NAME,
            class_name,
        )

        style_string = tag_object.get_attribute('style')
        match_list = re.findall('url\(\"(.*)\"\);', style_string)
        if match_list:
            return match_list[0]
        return
    return inner

bg_img_url = WebDriverWait(driver, 30, 0.5).until(fetch_image_func('geetest_bg'))
print(f'背景图:{bg_img_url}')


slice_image_url = WebDriverWait(driver, 30, 0.5).until(fetch_image_func('geetest_slice_bg'))
print(f'背景图:{slice_image_url}')

time.sleep(2)
driver.close()

t(f'背景图:{slice_image_url}')

time.sleep(2)

driver.close()

复制代码
相关推荐
深蓝电商API6 小时前
移动端APP抓包实战:Frida+SSL Pinning绕过的完整配置
爬虫
枫叶V8 小时前
Scrapling 入门:一个现代 Python 网页采集框架
后端·爬虫
YYueHua59 小时前
python3爬虫基础--HTTP基本原理
爬虫
靠谱品牌推荐官9 小时前
【架构实战】如何设计一套原生支持 GEO 大模型爬虫语义索引的 HTML5/CSS3 纯净白盒前端架构?
前端·爬虫·架构
烟雨江南aabb10 小时前
Python第七弹:爬虫篇:BeautifulSoup库
爬虫·python·beautifulsoup
深蓝电商API1 天前
请求签名算法破解:从Chrome DevTools到Python还原的完整流程
爬虫·反爬
DevnullCoffe2 天前
用 MCP 让 AI Agent 直接批量下载亚马逊商品图片——原理、踩坑与实现
爬虫·python·api
深蓝电商API2 天前
电商网站IP封禁绕过:代理池+流量指纹模拟的实战方案
爬虫
川冰ICE3 天前
Python爬虫实战⑳|Pandas时间序列,趋势分析一网打尽
爬虫·python·pandas
小白学大数据3 天前
Python 爬虫动态 JS 渲染与无头浏览器实战选型指南
开发语言·javascript·爬虫·python