图片转文字,文字转json数据(图片->文字->json)

1,017 阅读1分钟

一、图片转文字

1.利用OCR可以转为excel等文件

原图

2.这里用线上的 zhcn.109876543210.com/

3.我们转为.xls文件

转换后成这个样子

二、文字转JSON (利用Node)

1.新建个package.json.
内容为:
{
  "name": "abc",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "xls-to-json": "*"

  }
}
2.保存后直接npm install 安装包。然后新建app.js
node_xj = require("xls-to-json");
  node_xj({
    input: "test.xls",  // input xls 
    output: "output.json" // output json 
    //sheet: "sheet1",  // specific sheetname 
  }, function(err, result) {
    if(err) {
      console.error(err);
    } else {
      console.log(result);
    }
  });
3.将test.xls(你图片转出来的文件)放到相同目录,然后node app.js就行了。。
最后成果 完美