close #1454
This commit is contained in:
Chenyang Shi
2019-01-28 17:38:51 +08:00
committed by DIYgod
parent 36eae92311
commit 66cdae860a
3 changed files with 52 additions and 0 deletions

View File

@@ -2823,3 +2823,7 @@ board 和 build 可在[这里](http://api.ineal.me/tss/status)查看
### 政府
<route name="最新政策" author="SettingDust" example="/gov/zhengce/zuixin" path="/gov/zhengce/zuixin"/>
### 移动支付网
<route name="新闻" author="LogicJake" example="/mpaypass/news" path="/mpaypass/news"/>

View File

@@ -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;

View File

@@ -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()
),
};
};