diff --git a/docs/README.md b/docs/README.md index cba9209e1c..70c7755007 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2965,3 +2965,7 @@ board 和 build 可在[这里](http://api.ineal.me/tss/status)查看 ### 鲸跃汽车 + +### 每日安全 + + diff --git a/lib/router.js b/lib/router.js index 3fb48fc98b..51930b2f92 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1065,4 +1065,7 @@ router.get('/hupu/bxj/:id/:order?', require('./routes/hupu/bxj')); // 牛客网 router.get('/nowcoder/discuss/:type/:order', require('./routes/nowcoder/discuss')); +// 每日安全 +router.get('/security/pulses', require('./routes/security/pulses')); + module.exports = router; diff --git a/lib/routes/security/pulses.js b/lib/routes/security/pulses.js new file mode 100644 index 0000000000..17b6665e12 --- /dev/null +++ b/lib/routes/security/pulses.js @@ -0,0 +1,43 @@ +const axios = require('../../utils/axios'); +const cheerio = require('cheerio'); +const url = require('url'); + +const host = 'https://sec.today'; + +module.exports = async (ctx) => { + const link = 'https://sec.today/pulses/'; + const response = await axios.get(link); + const $ = cheerio.load(response.data); + + const out = $('div.endless_page_template div.row') + .slice(0, 10) + .map(function() { + const author = $(this) + .find('div.card-text small.text-muted') + .text() + .trim() + .split('•')[0]; + + const itemUrl = $(this) + .find('p.card-text.my-3 > a') + .attr('href'); + const info = { + link: url.resolve(host, itemUrl), + description: $(this) + .find('p.card-text.my-1') + .html(), + title: $(this) + .find('h5.card-title') + .text(), + author: author, + }; + return info; + }) + .get(); + + ctx.state.data = { + title: '每日安全推送', + link: link, + item: out, + }; +};