python实现腾讯滑块验证码识别
程序员文章站
2022-04-03 18:31:22
腾讯滑块验证码识别,识别凹槽的x轴位置,mock滑块的加速度。该项目公开api,提供识别和加速度模拟部分,第二部分模拟滑动进行识别返回数据请求项目地址:安装python环境参考:sudo yum in...
腾讯滑块验证码识别,识别凹槽的x轴位置,mock滑块的加速度。该项目公开api,提供识别和加速度模拟部分,第二部分模拟滑动进行识别返回数据请求
项目地址:
安装python环境
参考:
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 滑块验证码识别的资料请关注其它相关文章!