0%

用Docker部署识别12306验证码服务

12306验证码识别

这是一个基于Flask,Tensorflow,Keras实现的12306验证码识别接口。

搭建好的接口:https://mark12306captcha.wudinaonao.com

拉取镜像

1
docker pull wudinaonao/flask-mark-12306-captcha

启动镜像

docker

1
docker run -dit -p 8848:8848 wudinaonao/flask-mark-12306-captcha

docker compose

1
2
3
4
5
6
7
8
version: "3.1"
services:
flask-mark-12306-captcha:
image: wudinaonao/flask-mark-12306-captcha
container_name: flask-mark-12306-captcha
ports:
- 8848:8848
restart: always

一个用于验证的前端

访问:http://yourhostname:8848

20200609204007

API

获取验证码

从12306获取一张测试的验证码

  • Request

    • Method: GET
    • Headers
      • Content-Type: application/json
    • URL: /Mark12306Captcha/api/v1.0/get/captcha
  • Response

    • Headers
      • Content-Type: application/json
    • Body
      1
      2
      3
      4
      5
      {
      "status": "success",
      "message": "mark successfully",
      "result": "captcha base64 string"
      }

识别

Full

  • Request

    • Method: POST
    • Headers
      • Content-Type: application/json
    • URL: /Mark12306Captcha/api/v1.0/mark
    • Body
      • {"originCaptcha":"captcha base64 string"}
  • Response

    • Headers
      • Content-Type: application/json
    • Body
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      {
      "status": "success",
      "message": "mark successfully",
      "result": {
      "originCaptcha": "origin captcha base64 string",
      "ids": [
      5,
      7
      ],
      "results": [
      [
      190,
      165
      ],
      [
      260,
      141
      ]
      ],
      "markedCaptcha": "marked captcha base64 string"
      }
      }
  • Result 解释说明

    • ids 图片的编号
      • 0 2 4 6
        1 3 5 7
    • results 一个列表,每个元素是标记的坐标
    • markedCaptcha 绘制好标记结果的验证码Base64字符串

Lite

  • Request

    • Method: POST
    • Headers
      • Content-Type: application/json
    • URL: /Mark12306Captcha/api/v1.0/mark/lite
    • Body
      • {"originCaptcha":"captcha base64 string"}
  • Response

    • Headers
      • Content-Type: application/json
    • Body
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      {
      "status": "success",
      "message": "mark successfully",
      "result": [
      [
      168,
      144
      ],
      [
      274,
      125
      ]
      ]
      }
    • Result 解释说明参见上面

License

Apache License