diff --git a/docs/README.md b/docs/README.md index fb9b52d41d..51423a97f4 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2823,3 +2823,7 @@ board 和 build 可在[这里](http://api.ineal.me/tss/status)查看 ### 政府 + +### 移动支付网 + + diff --git a/lib/router.js b/lib/router.js index 40b41efd13..f0b64c60c5 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1006,4 +1006,6 @@ router.get('/gov/zhengce/zuixin', require('./routes/gov/zhengce/zuixin')); // 小黑盒 router.get('/xiaoheihe/user/:id', require('./routes/xiaoheihe/user')); +// 移动支付 +router.get('/mpaypass/news', require('./routes/mpaypass/news')); module.exports = router; diff --git a/lib/routes/mpaypass/news.js b/lib/routes/mpaypass/news.js new file mode 100644 index 0000000000..086246e62e --- /dev/null +++ b/lib/routes/mpaypass/news.js @@ -0,0 +1,46 @@ +const axios = require('../../utils/axios'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const link = `http://m.mpaypass.com.cn/`; + const listData = await axios.get(link); + const $list = cheerio.load(listData.data); + ctx.state.data = { + title: `新闻 - 移动支付网`, + link, + item: await Promise.all( + $list('.newsbodylist') + .map(async (_, el) => { + const $el = $list(el); + const $a = $el.find('.newsbodylist-title a'); + const href = $a.attr('href'); + const title = $a.text(); + const date = $el + .find('.newsbodylist-title span') + .text() + .split('|')[1]; + + const key = `${href}`; + let description; + const value = await ctx.cache.get(key); + + if (value) { + description = value; + } else { + const contentData = await axios.get(href); + const $content = cheerio.load(contentData.data); + description = $content('.newsbody').html(); + ctx.cache.set(key, description, 24 * 60 * 60); + } + + return { + title: title, + description, + link: href, + pubDate: new Date(date).toUTCString(), + }; + }) + .get() + ), + }; +};