Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
马玮
/
carspider
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
0f13c593
authored
Aug 25, 2017
by
马玮
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix await
parent
3a7fcc58
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
28 additions
and
23 deletions
+28
-23
boot.js
+21
-15
lib/DI.js
+2
-2
lib/spider/dealer/Autohome.js
+3
-4
lib/spider/dealer/Easypass.js
+1
-1
lib/spider/index.js
+1
-1
test.js
+0
-0
No files found.
boot.js
View file @
0f13c593
...
@@ -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
lib/DI.js
View file @
0f13c593
...
@@ -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
)
{
...
...
lib/spider/dealer/Autohome.js
View file @
0f13c593
...
@@ -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'
,
{
a
wait
a
xios
.
get
(
'http://ics.Autohome.com.cn/Dms/Order/SearchOrderList'
,
{
params
:
params
,
params
:
params
,
headers
:{
headers
:{
Cookie
:
headerCookie
Cookie
:
headerCookie
...
...
lib/spider/dealer/Easypass.js
View file @
0f13c593
...
@@ -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
...
...
lib/spider/index.js
View file @
0f13c593
...
@@ -32,7 +32,7 @@ class Spider {
...
@@ -32,7 +32,7 @@ class Spider {
}
}
async
execute
()
{
async
execute
()
{
this
.
spider
.
execute
();
await
this
.
spider
.
execute
();
}
}
}
}
...
...
test.js
View file @
0f13c593
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment