Commit 0f13c593 by 马玮

Fix await

parent 3a7fcc58
...@@ -49,24 +49,29 @@ if (commandError.length > 0) { ...@@ -49,24 +49,29 @@ if (commandError.length > 0) {
const spider = new Spider(params); const spider = new Spider(params);
await spider.execute(); await spider.execute();
// console.timeEnd('程序耗时'); console.timeEnd('程序耗时');
// process.exit(0);
return;
const rl = readline.createInterface({ const rl = readline.createInterface({
input: process.stdin, input: process.stdin,
output: process.stdout output: process.stdout
}); });
// rl.write('正在释放资源...\n预计3秒后退出: ');
// DI.shutdownLogger(async () => { DI.shutdownLogger(() => {
// for (let i = 3; i > 0; i -= 1) { // do nothing
// rl.write(String(i)); });
// await Promise.delay(1000);
// readline.moveCursor(process.stdout,-1); rl.write('正在释放资源...\n预计3秒后退出: ');
// } for (let i = 3; i > 0; i -= 1) {
// readline.clearLine(process.stdout, 0); rl.write(String(i));
// readline.moveCursor(process.stdout, -1, -1); await Promise.delay(1000);
// rl.write('\n'); readline.moveCursor(process.stdout,-1);
// rl.close(); }
// console.log('程序结束'); readline.clearLine(process.stdout, 0);
// process.exit(0); readline.moveCursor(process.stdout, -1, -1);
// }); rl.write('\n');
rl.close();
console.log('程序结束');
process.exit(0);
})(); })();
\ No newline at end of file
...@@ -9,7 +9,7 @@ class DI { ...@@ -9,7 +9,7 @@ class DI {
} }
static getLogger() { static getLogger() {
const level = process.env.LOG_LEVEL || 'info'; const level = process.env.LOG_LEVEL || 'debug';
log4js.configure({ log4js.configure({
appenders: { appenders: {
console: { type: 'console' }, console: { type: 'console' },
...@@ -19,7 +19,7 @@ class DI { ...@@ -19,7 +19,7 @@ class DI {
default: { appenders: [ 'console', 'carspider' ], level: level } default: { appenders: [ 'console', 'carspider' ], level: level }
} }
}); });
return log4js.getLogger(); return log4js.getLogger('SPIDER');
} }
static shutdownLogger(cb) { static shutdownLogger(cb) {
......
...@@ -39,8 +39,7 @@ class Autohome extends Base { ...@@ -39,8 +39,7 @@ class Autohome extends Base {
return; return;
} }
case 'fetchClues': { case 'fetchClues': {
await this.fetchClues(); return await this.fetchClues();
return;
} }
} }
} }
...@@ -202,7 +201,7 @@ class Autohome extends Base { ...@@ -202,7 +201,7 @@ class Autohome extends Base {
params.provinceId = -2; params.provinceId = -2;
params.cityId = -2; params.cityId = -2;
params.status = -1; params.status = -1;
params.startTime = moment().subtract(90, 'days').format('YYYY.MM.DD'); params.startTime = moment().subtract(3, 'days').format('YYYY.MM.DD');
params.endtime = moment().format('YYYY.MM.DD'); params.endtime = moment().format('YYYY.MM.DD');
params.pageIndex = 1 params.pageIndex = 1
params.pageSize = 20; params.pageSize = 20;
...@@ -215,7 +214,7 @@ class Autohome extends Base { ...@@ -215,7 +214,7 @@ class Autohome extends Base {
logger.info(`线索日期: ${params.startTime} - ${params.endtime}`); logger.info(`线索日期: ${params.startTime} - ${params.endtime}`);
} }
logger.info(`线索页面: ${params.pageIndex}`); logger.info(`线索页面: ${params.pageIndex}`);
axios.get('http://ics.Autohome.com.cn/Dms/Order/SearchOrderList', { await axios.get('http://ics.Autohome.com.cn/Dms/Order/SearchOrderList', {
params: params, params: params,
headers:{ headers:{
Cookie: headerCookie Cookie: headerCookie
......
...@@ -195,7 +195,7 @@ class Easypass extends Base { ...@@ -195,7 +195,7 @@ class Easypass extends Base {
console.log('networkRequest', networkRequest); console.log('networkRequest', networkRequest);
}); });
const txtBeginTime = moment().subtract(90, 'days').format('YYYY-MM-DD'); const txtBeginTime = moment().subtract(15, 'days').format('YYYY-MM-DD');
await await
horseman horseman
......
...@@ -32,7 +32,7 @@ class Spider { ...@@ -32,7 +32,7 @@ class Spider {
} }
async execute() { async execute() {
this.spider.execute(); await this.spider.execute();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment