Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
spider-ufo
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
lzhy
5 years ago
Commit
d83f836afad9b53710b505b54b74928af7da0b8e
1 parent
9e7b84a8
增加爬取数据开始结束的监听
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
1 deletions
tasks/spider-task.js
tasks/spider-task.js
View file @
d83f836
...
...
@@ -9,6 +9,9 @@ const {logger} = require('../libs/logger');
const
{
sendMessage
}
=
require
(
'../libs/influx-report'
);
const
{
getSpecialSizeProducts
,
getSize
}
=
require
(
'../utils'
);
const
ddAlert
=
require
(
'../libs/dingding-alert'
);
const
moment
=
require
(
'moment'
);
// const {SknRecord} = require('../models');
// const md5 = require('yoho-md5');
...
...
@@ -21,6 +24,8 @@ const {getSpecialSizeProducts, getSize} = require('../utils');
// }
module
.
exports
=
async
(
time
)
=>
{
const
beginTime
=
moment
(
Date
.
now
()).
format
(
'YYYY-MM-DD HH:mm:ss'
);
ddAlert
(
`监控报警
:
爬取毒数据开始
—
$
{
beginTime
}
`
,
'bjSpider'
);
const
specialSizeProducts
=
await
getSpecialSizeProducts
();
const
sizeData
=
await
mysqlPool
.
query
(
'select `size_name`,min(`id`) as id from `size` where `size_name` <> \'-\' group by `size_name`'
);
const
sizeRelation
=
{};
...
...
@@ -47,7 +52,7 @@ module.exports = async(time) => {
// }
logger
.
info
(
`
[
spiderTask
]
time
:
$
{
time
},
product_number
:
$
{
sknsData
&&
sknsData
.
length
}
`
);
var
n
=
0
;
spider
(
sknsData
.
map
(
p
=>
p
.
productId
),
''
,
{},
1000
)
.
forEach
(
promise
=>
promise
.
then
(
result
=>
{
if
(
result
.
status
!==
200
&&
!
_
.
has
(
result
,
'data.detail'
))
{
...
...
@@ -99,5 +104,10 @@ module.exports = async(time) => {
});
}
});
n
++
;
if
(
n
==
sknsData
.
length
)
{
const
endTime
=
moment
(
Date
.
now
()).
format
(
'YYYY-MM-DD HH:mm:ss'
);
ddAlert
(
`监控报警
:
爬取毒数据结束
—
$
{
endTime
}
`
,
'bjSpider'
);
}
}));
};
...
...
Please
register
or
login
to post a comment