From a7912ec297057c8bcfd419007f57e894602248f1 Mon Sep 17 00:00:00 2001 From: Fan Shen <1370275510@qq.com> Date: Wed, 8 May 2019 16:47:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20add=207x24=E5=B0=8F=E6=97=B6=E5=BF=AB?= =?UTF-8?q?=E8=AE=AF=20(#2069)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/other.md | 4 ++++ lib/router.js | 3 +++ lib/routes/fx678/kx.js | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 lib/routes/fx678/kx.js diff --git a/docs/other.md b/docs/other.md index b0956f8c4..5bfdf13ba 100644 --- a/docs/other.md +++ b/docs/other.md @@ -517,6 +517,10 @@ type 为 all 时,category 参数不支持 cost 和 free +## 7x24 小时快讯 + + + ## gradCafe(一个比较流行的国外研究生录取结果通知) diff --git a/lib/router.js b/lib/router.js index 5fec58db4..2d7829fa8 100755 --- a/lib/router.js +++ b/lib/router.js @@ -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; diff --git a/lib/routes/fx678/kx.js b/lib/routes/fx678/kx.js new file mode 100644 index 000000000..d6d85911a --- /dev/null +++ b/lib/routes/fx678/kx.js @@ -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, + }; +};