From bbb7960d5174658f70d56383bd563503edfcdd32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=AB=E8=B0=B7=E5=89=91=E4=BB=99?= Date: Sun, 16 Jun 2019 16:34:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=80=AA=E7=89=A9=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E5=86=85=E6=96=87=E4=BB=B6=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +- monsters-info/extractByNode.js | 67 ++++++++++------------ monsters-info/extract_CHT.js | 48 ++++++++++++++++ monsters-info/{ => official-API}/test.html | 0 monsters-info/提取中文数据.bat | 7 +++ 5 files changed, 86 insertions(+), 39 deletions(-) create mode 100644 monsters-info/extract_CHT.js rename monsters-info/{ => official-API}/test.html (100%) create mode 100644 monsters-info/提取中文数据.bat diff --git a/.gitignore b/.gitignore index 629b2932..412af3b1 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -monsters-info/Download-pad.skyozora.com \ No newline at end of file +/monsters-info/Download-pad.skyozora.com +/monsters-info/opencc diff --git a/monsters-info/extractByNode.js b/monsters-info/extractByNode.js index 8b12350b..621a60c4 100644 --- a/monsters-info/extractByNode.js +++ b/monsters-info/extractByNode.js @@ -1,40 +1,31 @@ var fs = require('fs'); +var officialAPI = ["ja","en","ko"]; //来源于官方API +var custom = ["cht","chs"]; //来源于自定义文件 -console.log('正在读取日文怪物信息'); -var ja_json = fs.readFileSync("./ja.json", 'utf-8'); //使用同步读取 -var ja = JSON.parse(ja_json);//将字符串转换为json对象 -var msja = ja.card; -console.log('正在读取英文怪物信息'); -var en_json = fs.readFileSync("./en.json", 'utf-8'); //使用同步读取 -var en = JSON.parse(en_json);//将字符串转换为json对象 -var msen = en.card; -console.log('正在读取韩文怪物信息'); -var ko_json = fs.readFileSync("./ko.json", 'utf-8'); //使用同步读取 -var ko = JSON.parse(ko_json);//将字符串转换为json对象 -var msko = ko.card; -var mArr = []; +var cards = officialAPI.map(function(code){ + console.log("正在读取官方 " + code + " 信息"); + var json = fs.readFileSync("official-API/" + code +".json", 'utf-8'); //使用同步读取 + var card = JSON.parse(json).card;//将字符串转换为json对象 + return card; +}) -for (var mi=0;mi\s*?([\s\S]+)\s*?<\/h2>/igm.exec(htmlText); + try + { + var m = { + id:searchID[1], + name:searchName[1].replace("\n",""), + } + monArr.push(m); + if (monArr.length % 100 == 0) + { + console.log("已读取 " + monArr.length + " 个网页"); + } + }catch(e) + { + console.log(filename,e) + } + } + }); + monArr.sort(function(a,b){ + return a.id - b.id; + }) + var str = JSON.stringify(monArr); + fs.writeFile(outJSON,str,function(err){ + if(err){ + console.error(err); + } + console.log("---繁体中文导出成功,共 " + monArr.length + " 个名称---"); + }) + } +}); \ No newline at end of file diff --git a/monsters-info/test.html b/monsters-info/official-API/test.html similarity index 100% rename from monsters-info/test.html rename to monsters-info/official-API/test.html diff --git a/monsters-info/提取中文数据.bat b/monsters-info/提取中文数据.bat new file mode 100644 index 00000000..b5706603 --- /dev/null +++ b/monsters-info/提取中文数据.bat @@ -0,0 +1,7 @@ +@echo off +echo ʼȡҳ +node.exe extract_CHT.js +echo ڽתΪ +opencc\opencc.exe -i custom\CHT.json -o custom\CHS.json -c opencc\t2s.json +echo ת +pause \ No newline at end of file