|
|
@@ -20,13 +20,24 @@ if (!info || !info[0] || !info[0][0] || !info[0][1] || info[0][0] === 'reply_inf
|
|
|
|
|
|
let infoOK = [];
|
|
|
|
|
|
+function fillZero(num) {
|
|
|
+ return (num < 10) ? "0" + num : "" + num;
|
|
|
+}
|
|
|
+
|
|
|
function getDate() {
|
|
|
const now = new Date();
|
|
|
- return now.getFullYear() + "-" +
|
|
|
- ((now.getMonth() + 1 < 10) ? "0" + (now.getMonth() + 1) : (now.getMonth() + 1)) + "-" +
|
|
|
- ((now.getDate() < 10) ? "0" + now.getDate() : now.getDate());
|
|
|
+ return now.getFullYear() + "-" + fillZero(now.getMonth() + 1) + "-" + fillZero(now.getDate());
|
|
|
+}
|
|
|
+
|
|
|
+function getFullTime() {
|
|
|
+ const now = new Date();
|
|
|
+ const year = now.getFullYear(), month = now.getMonth() + 1, day = now.getDate(), hour = now.getHours(),
|
|
|
+ min = now.getMinutes(), sec = now.getSeconds();
|
|
|
+ return year + "-" + fillZero(month) + "-" + fillZero(day) + " " + fillZero(hour) + ":" + fillZero(min) + ":" +
|
|
|
+ fillZero(sec);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
async function interval() {
|
|
|
const browser = await puppeteer.launch({
|
|
|
// headless: false, // 是否隐藏窗口(默认true)
|
|
|
@@ -53,7 +64,7 @@ async function interval() {
|
|
|
try {
|
|
|
await run(browser, info[i][0], info[i][1]);
|
|
|
} catch (e) {
|
|
|
- console.log("[" + hour + " " + min + " " + sec + "]", i, e);
|
|
|
+ console.log("[ " + getFullTime() + " ]", i, e);
|
|
|
setTimeout(function () {
|
|
|
infoOK[i] = false; // 出错,一分钟后重试
|
|
|
}, 60000);
|
|
|
@@ -124,7 +135,7 @@ async function run(browser, replyInfo, sign) {
|
|
|
if (response.url() === "https://testmis.ssti.net.cn/xswxcs/Api/MedicalObHandle.ashx?action=add") {
|
|
|
const data = await response.json();
|
|
|
if (data["msg"].indexOf("成功") !== -1) {
|
|
|
- console.log(name + " 成功");
|
|
|
+ console.log("[ " + getFullTime() + " ]" + name + " 成功");
|
|
|
try {
|
|
|
await page.screenshot({path: "img/" + name + "-" + getDate() + '.png'});
|
|
|
} catch (e) {
|