爬虫(滑块验证的破解)

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

复制代码
相关推荐
数据狐(Datafox)13 分钟前
1688商品列表API接口解析(附 JSON 样例)
java·开发语言·数据库·爬虫·json
深蓝电商API1 小时前
大语言模型能否自动完成 JS 逆向?
爬虫·js逆向
不叫猫先生1 小时前
2026 Web Scraping 代理服务商怎么选?住宅代理与代理网络对比指南
爬虫·网络代理·代理·住宅代理
SEO_juper16 小时前
Java 并发编程实战:从线程基础到高并发架构
运维·人工智能·爬虫·chatgpt·seo
大数据魔法师21 小时前
curl_cffi从入门到实战
爬虫·python
2601_960102041 天前
2026新破甲AI站群泛程序
爬虫·搜索引擎·蜘蛛池
深蓝电商API1 天前
AI 如何辅助编写爬虫?
爬虫
狗都不学爬虫_1 天前
AI逆向 - 天御无感点击验证(补+纯)
爬虫·python·网络爬虫
小静AI工程实验室1 天前
Python 爬虫翻页为何重复、漏数据?SQLite 复现 OFFSET、复合游标与快照的 8 项检查
爬虫·python·sqlite
码农学院1 天前
制造业B2B官网GEO实战:用 Python 向量相似度给老产品手册自动补语义内链,让 AI 爬虫抓得更深
运维·人工智能·爬虫·ai优化aio