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
e01acff0
authored
Aug 30, 2017
by
马玮
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Op logs
parent
c96c86c7
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
37 deletions
+11
-37
lib/DI.js
+3
-2
lib/spider/Base.js
+8
-0
lib/spider/dealer/Autohome.js
+0
-18
lib/spider/dealer/Easypass.js
+0
-17
No files found.
lib/DI.js
View file @
e01acff0
...
...
@@ -23,11 +23,12 @@ class DI {
static
getLogger
()
{
const
level
=
process
.
env
.
LOG_LEVEL
||
'info'
;
const
appenders
=
(
process
.
env
.
LOG_TYPE
?
process
.
env
.
LOG_TYPE
.
split
(
','
)
:
null
)
||
[
'console'
,
'carspider'
];
// maxLogSize: 10485760
// 按文件大小回滚配置,待以后备用
// { type: 'file', filename: `${__basedir}/logs/dealer/carspider.log`, maxLogSize: 10485760, backups: 3, compress: false }
log4js
.
configure
({
appenders
:
{
console
:
{
type
:
'console'
},
carspider
:
{
type
:
'
file'
,
filename
:
`
${
__basedir
}
/logs/dealer/carspider.log`
,
maxLogSize
:
1048576
,
backups
:
3
,
compress
:
false
},
carspider
:
{
type
:
'
dateFile'
,
filename
:
`
${
__basedir
}
/logs/dealer/carspider.log`
},
},
categories
:
{
default
:
{
appenders
:
appenders
,
level
:
level
}
...
...
lib/spider/Base.js
View file @
e01acff0
...
...
@@ -17,6 +17,14 @@ class Base {
this
.
maxLoginTimes
=
3
;
}
async
execute
()
{
try
{
await
this
[
this
.
params
.
task
]();
}
catch
(
e
)
{
logger
.
fatal
(
`accountID:
${
this
.
params
.
accountID
}
, 系统异常:
${
e
}
`
);
}
}
async
login
()
{
console
.
log
(
'子类需要重载此方法'
);
}
...
...
lib/spider/dealer/Autohome.js
View file @
e01acff0
...
...
@@ -27,24 +27,6 @@ class Autohome extends Base {
this
.
params
=
params
;
}
async
execute
()
{
try
{
switch
(
this
.
params
.
task
)
{
case
'login'
:
{
return
await
this
.
login
();
}
case
'tryLogin'
:
{
return
await
this
.
tryLogin
();
}
case
'fetchClues'
:
{
return
await
this
.
fetchClues
();
}
}
}
catch
(
e
)
{
logger
.
fatal
(
`accountID:
${
this
.
params
.
accountID
}
, 系统异常:
${
e
}
`
);
}
}
async
tryLogin
()
{
// 随机返回登录状态
// return [new errors.TryLoginError('登录失效'), randomInt(0, 1)];
...
...
lib/spider/dealer/Easypass.js
View file @
e01acff0
...
...
@@ -27,23 +27,6 @@ class Easypass extends Base {
this
.
params
=
params
;
}
async
execute
()
{
switch
(
this
.
params
.
task
)
{
case
'login'
:
{
await
this
.
login
();
return
;
}
case
'tryLogin'
:
{
await
this
.
tryLogin
();
return
;
}
case
'fetchClues'
:
{
await
this
.
fetchClues
();
return
;
}
}
}
async
tryLogin
()
{
// 随机返回登录状态
// return [new errors.TryLoginError('登录失效'), randomInt(0, 1)];
...
...
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