温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

python如何实现腾讯滑块验证码识别

发布时间:2021-04-30 10:36:08 来源:亿速云 阅读:314 作者:小新 栏目:开发技术

小编给大家分享一下python如何实现腾讯滑块验证码识别,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!

python的五大特点是什么

python的五大特点:1.简单易学,开发程序时,专注的是解决问题,而不是搞明白语言本身。2.面向对象,与其他主要的语言如C++和Java相比, Python以一种非常强大又简单的方式实现面向对象编程。3.可移植性,Python程序无需修改就可以在各种平台上运行。4.解释性,Python语言写的程序不需要编译成二进制代码,可以直接从源代码运行程序。5.开源,Python是 FLOSS(自由/开放源码软件)之一。

安装python环境

参考:https://janikarhunen.fi/how-to-install-python-3-6-1-on-centos-7

sudo yum install https://centos7.iuscommunity.org/ius-release.rpm
sudo yum install python36u
python3.6 -V
sudo yum install python36u-pip
sudo yum install python36u-devel

创建环境 Creating a virtualenv

python3.6 -m venv venv
. venv/bin/activate
pip install [package_name]
# 安装依赖
pip install -r requirements.txt

daemonize 运行

# 参考 https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uswgi-and-nginx-on-ubuntu-18-04
# Install the latest stable release:
pip install uwsgi
# ... or if you want to install the latest LTS (long term support) release,
pip install https://projects.unbit.it/downloads/uwsgi-lts.tar.gz

# 创建ln 
cp captcha.service /etc/systemd/system/captcha.service
systemctl enable captcha.service
systemctl start captcha.service
uwsgi --ini /usr/local/nginx/html/myblog/uwsgiconfig.ini

#后台运行
uwsgi --ini /usr/local/nginx/html/myblog/uwsgiconfig.ini --daemonize /usr/local/nginx/html/myblog/myblog.out

nginx做代理

location /tx/ {
            add_header Access-Control-Allow-Origin *;
            include        uwsgi_params;
            uwsgi_pass     127.0.0.1:8008;
        }

访问api

请求图片识别和加速度模拟

http://127.0.0.1:5000/tx/image

POST /tx/image HTTP/1.1
Host:host
Content-Type: application/json
Accept: */*
Cache-Control: no-cache
Accept-Encoding: gzip, deflate
Content-Length: 1055
Connection: keep-alive
cache-control: no-cache

{
    "url": "图片的地址"
}

返回数据

{
    "data": {
        "list": [],//模拟的点
        "url": "",//图片地址
        "x": 515,// x轴的偏移量
    },
    "message": "解析成功"
}

模拟浏览器移动

const slider = {width: 680, point: 0, move: 0, steps: 0, posX: 0};//原本的高度
            //开始计算移动的距离
            slider.point = bgSize.width / slider.width * x;
            slider.move = handle.x + slider.point - 5;
            slider.steps = Math.random() * 100 / 30 + 100;
            slider.posX = handle.x + handle.width / 2;

            logger.info(`开始识别和移动滑块`, slider);

            //滑块的位置
            await page.mouse.move(slider.posX, handle.y + handle.height / 3, {steps: slider.steps});
            await page.mouse.down();
            let val = handle.x;
            for (let i = 0; i < traces.length; i++) {
                val += bgSize.width / slider.width * (traces[i]);//缩放距离
                slider.move = val;
                if (val <= slider.posX) continue;
                await page.mouse.move(slider.move, handle.y + handle.height / 2 + 5);
            }
            await page.waitFor(100);
            await page.mouse.up();

验证码识别成功后悔返回验证识别结果的Ticket

python如何实现腾讯滑块验证码识别

看完了这篇文章,相信你对“python如何实现腾讯滑块验证码识别”有了一定的了解,如果想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI