国税总局增值税发票查验平台验证码识别深度学习实战

国家税务总局全国增值税发票查验平台验证码

查验验证码图片如下面所示:

国税总局增值税发票查验平台验证码识别深度学习实战_第1张图片

测试地址:http://47.99.174.98:8808/

1.验证码识别Python版

import base64
import requests

with open('./tmp.jpg', 'rb') as f:
    img_bytes = f.read()

img_base64 = base64.b64encode(img_bytes)
# '00' 黑色 '01' 红色 '02' 黄色 '03' 蓝色
data = {
     'image': str(img_base64, 'utf-8'), 'key': '01'}
result = requests.post('http://47.99.174.98:8808/captcha', json=data)
print(result.text)
print(result.json())

2.验证码识别Java版

import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Base64;


public class CaptchaRecognize {
     
    static String captcha_url = "http://47.99.174.98:8808/captcha";

    public static String getBase64(String imgFile) {
     
        InputStream inputStream = null;
        byte[] data = null;
        try {
     
            inputStream = new FileInputStream(imgFile);
            data = new byte[inputStream.available()];
            inputStream.read(data);
            inputStream.close();

        } catch (IOException e) {
     
            e.printStackTrace();
        }
        Base64.Encoder encoder = Base64.getEncoder();
        assert data != null;
        return encoder.encodeToString(data);
    }

    public static void captchaPost() throws IOException {
     
        String imgBase64 = getBase64("./imgs/img001.jpg");
        String data = "{" + "\"image\":" + "\"" + imgBase64 + "\"" + "," + "\"key\":" + "\"03\"" + "}";
        URL url = new URL(captcha_url);
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestMethod("POST");
        conn.setDoOutput(true);
        conn.setDoInput(true);
        conn.setRequestProperty("Content-Type", "application/json");
        conn.setRequestProperty("Accept", "application/json");
        OutputStreamWriter out = new OutputStreamWriter(conn.getOutputStream());
        out.write(data);
        out.flush();
        out.close();
        BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
        String line;
        while ((line = in.readLine()) != null) {
     
            System.out.println(line); // {"code": "Y2W"}
        }
    }
    public static void main(String[] args) throws IOException {
     
        captchaPost();
    }
}

3.免验证码发票查验Python版

import requests
# fpdm 发票代码 fphm 发票号码 rq 开票日期 jym 校验码后六位(专票为不含税金额)
data = {
     'fpdm': '044001505121', 'fphm': '38507145', 'rq': '20180926', 'jym': '865375'}
result = requests.post('http://47.99.174.98:8808/fp', json=data)
print(result.json())

你可能感兴趣的:(国税局验证码识别,深度学习)