iaunco 6 éve
szülő
commit
c778ba37a8
5 módosított fájl, 32 hozzáadás és 12 törlés
  1. 2 1
      .gitignore
  2. 1 3
      README.md
  3. 12 0
      config.example.js
  4. 17 8
      index.js
  5. BIN
      自动提交申报工具使用.docx

+ 2 - 1
.gitignore

@@ -1,3 +1,4 @@
 node_modules/
 img/
-.idea/
+.idea/
+config.js

+ 1 - 3
README.md

@@ -7,11 +7,9 @@
 npm install -g cnpm --registry=https://registry.npm.taobao.org
 cnpm i --registry=https://registry.npm.taobao.org
 ```
-
 ```
-# ===修改index.js的info数组(按照word抓包操作)===
+# ===修改info数组(按照word抓包操作)===
 ```
-
 ```
 # 运行程序
 node index.js

+ 12 - 0
config.example.js

@@ -0,0 +1,12 @@
+// COPY this file to config.js
+
+// need: reply_info, sign
+// from url: https://testmis.ssti.net.cn/xswxcs/?reply_info=******&sign=******
+function config() {
+    return [
+        // *** 在此处填写/修改reply_info和sign ***
+        ['reply_info', 'sign']
+    ];
+}
+
+module.exports = config;

+ 17 - 8
index.js

@@ -1,12 +1,22 @@
 const puppeteer = require('puppeteer');
 const fs = require('fs');
-
-
-//need: reply_info, sign
-//from url: https://testmis.ssti.net.cn/xswxcs/?reply_info=******&sign=******
-const info = [
-    ['reply_info', 'sign']
-];
+let info;
+try {
+    info = require('./config')();
+} catch (e) {
+    try {
+        info = require('./config.example')();
+    } catch (e) {
+        console.log("配置文件错误");
+        process.exit();
+        return;
+    }
+}
+if (!info || !info[0] || !info[0][0] || !info[0][1] || info[0][0] === 'reply_info' || info[0][1] === 'sign') {
+    console.log("配置文件错误");
+    process.exit();
+    return;
+}
 
 let infoOK = [];
 
@@ -133,7 +143,6 @@ async function run(browser, replyInfo, sign) {
                 await page.close();
                 reject("Unknown URL: " + response.url());
             }
-
         });
         try {
             await page.click("#Apply_Epidemic");

BIN
自动提交申报工具使用.docx