feat: add 7x24小时快讯 (#2069)
This commit is contained in:
parent
b2c502e0af
commit
a7912ec297
|
|
@ -517,6 +517,10 @@ type 为 all 时,category 参数不支持 cost 和 free
|
|||
|
||||
<Route name="洞察" author="LogicJake" example="/kpmg/insights" path="/kpmg/insights" />
|
||||
|
||||
## 7x24 小时快讯
|
||||
|
||||
<Route name="7x24小时快讯" author="occupy5" example="/fx678/kx" path="/fx678/kx" />
|
||||
|
||||
## gradCafe(一个比较流行的国外研究生录取结果通知)
|
||||
|
||||
<Route name="gradCafe result" author="liecn" example="/gradcafe/result" path="/gradcafe/result" />
|
||||
|
|
|
|||
|
|
@ -1326,4 +1326,7 @@ router.get('/the-economist/gre-vocabulary', require('./routes/the-economist/gre-
|
|||
router.get('/asahichinese-f/:category/:subCate', require('./routes/asahichinese-f/index'));
|
||||
router.get('/asahichinese-f/:category', require('./routes/asahichinese-f/index'));
|
||||
|
||||
// 7x24小时快讯
|
||||
router.get('/fx678/kx', require('./routes/fx678/kx'));
|
||||
|
||||
module.exports = router;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
const cheerio = require('cheerio');
|
||||
const axios = require('../../utils/axios');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const url = 'https://kx.fx678.com/';
|
||||
const res = await axios.get(url);
|
||||
const $ = cheerio.load(res.data);
|
||||
|
||||
const list = $('.body_zb ul .body_zb_li');
|
||||
// 爬取页面的前30条消息
|
||||
const content = list
|
||||
.slice(0, 30)
|
||||
.map(function() {
|
||||
const title = $(this)
|
||||
.find('.zb_time')
|
||||
.text();
|
||||
const description = $(this)
|
||||
.find('.zb_word')
|
||||
.text()
|
||||
.replace(/(^\s*)|(\s*$)/g, '');
|
||||
const item = {
|
||||
title,
|
||||
description,
|
||||
};
|
||||
return item;
|
||||
})
|
||||
.get();
|
||||
|
||||
ctx.state.data = {
|
||||
title: '7x24小时快讯',
|
||||
link: url,
|
||||
item: content,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue