爬虫(滑块验证的破解)

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

复制代码
相关推荐
程序员威哥1 天前
实战!Python爬京东商品评论:从采集到情感分析+词云可视化,新手30分钟跑通
开发语言·爬虫·python·scrapy
S1998_1997111609•X2 天前
哈希树函数洪水泛滥污染孪生镜像导致生物量子信息泄露以钩子而爬虫植入ssd探测
爬虫·网络协议·缓存·哈希算法·开闭原则
捉鸭子2 天前
QQ音乐sign vmp逆向
爬虫·python·网络安全·网络爬虫
上海云盾王帅2 天前
如何防御爬虫攻击:告别数据被扒,构建智能业务风控体系
爬虫
不会飞的鲨鱼2 天前
观鸟网 RSA加密 AES 解密
javascript·爬虫·python
pengyi8710152 天前
HTTP与HTTPS代理基础区别,协议原理通俗解析
网络·爬虫·网络协议·tcp/ip·智能路由器
科技牛牛2 天前
AI爬虫引爆代理IP产业:一场正在发生的数据粮草争夺战
人工智能·爬虫·tcp/ip·数据安全·ip地址查询
小白学大数据2 天前
JS 混淆加密下的 Python 爬虫解决方案
javascript·爬虫·python
艺杯羹3 天前
Tkinter实战:为CSDN爬虫打造可视化界面,从GUI到多线程完整方案
爬虫·python·开源