爬虫(滑块验证的破解)

基于滑块的验证破解 ------ 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()

复制代码
相关推荐
Chengbei112 小时前
JsOwl|AI 赋能 JS 敏感信息扫描器,AST + 正则、source‑map 源码还原、登录态爬虫输出交互式 HTML 报告
开发语言·javascript·网络·人工智能·爬虫·网络安全·自动化
远航计算机4 小时前
AI 答案里的链接,为什么开始分等级了?
大数据·人工智能·爬虫·aigc
Novproxy_Z4 小时前
爬虫任务被拦截:区分 IP 封禁、设备封禁、账号封禁
爬虫·网络协议·tcp/ip
郝学胜-神的一滴5 小时前
Python浏览器自动化:Selenium与Playwright实战对比,网页爬虫&自动操作一站式指南
开发语言·爬虫·python·selenium·程序人生·自动化
Python大数据分析@19 小时前
通过 MCP 实现 AI Agent自动化数据采集
运维·人工智能·爬虫·自动化
深蓝电商API21 小时前
Docker+K8s部署爬虫:从单机到集群的完整路线
爬虫·docker·k8s
深蓝电商API1 天前
亿级数据的存储选型:MongoDB/ES/ClickHouse横评
爬虫·clickhouse·mongodb·elasticsearch
重生之高冷汉堡包2 天前
YouTube 数据抓取出现 429/403 错误?2026 反爬机制拆解与爬虫选型指南
爬虫
钱栈up2 天前
扫完 3.5 万文件后,我发现了 521 组散落的同名文件
爬虫·python·数据分析
B2_Proxy2 天前
aiohttp 异步爬虫如何配置代理?连接池复用与超时控制实战
爬虫