mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 23:00:48 +08:00
@@ -849,6 +849,11 @@ type 为 all 时,category 参数不支持 cost 和 free
|
||||
|
||||
<Route author="LogicJake" example="/mpaypass/news" path="/mpaypass/news"/>
|
||||
|
||||
### 分类
|
||||
|
||||
<Route author="zhuan-zhu" example="/mpaypass/main/policy" path="mpaypass/main/:type?"
|
||||
:paramsDesc="['新闻类型,类型可在URL中找到,类似policy,eye等,空或其他任意值展示最新新闻']"/>
|
||||
|
||||
## 油价
|
||||
|
||||
### 今日油价
|
||||
|
||||
@@ -1014,6 +1014,7 @@ router.get('/fitchratings/site/:type', require('./routes/fitchratings/site'));
|
||||
|
||||
// 移动支付
|
||||
router.get('/mpaypass/news', require('./routes/mpaypass/news'));
|
||||
router.get('/mpaypass/main/:type?', require('./routes/mpaypass/main'));
|
||||
|
||||
// 新浪科技探索
|
||||
router.get('/sina/discovery/:type', require('./routes/sina/discovery'));
|
||||
|
||||
81
lib/routes/mpaypass/main.js
Normal file
81
lib/routes/mpaypass/main.js
Normal file
@@ -0,0 +1,81 @@
|
||||
const axios = require('../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
let title_url = '';
|
||||
const { type = '' } = ctx.params;
|
||||
if (type) {
|
||||
title_url = `http://www.mpaypass.com.cn/${type}.html`;
|
||||
} else {
|
||||
title_url = 'http://www.mpaypass.com.cn';
|
||||
}
|
||||
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: title_url,
|
||||
});
|
||||
|
||||
const data = response.data;
|
||||
|
||||
const $ = cheerio.load(data);
|
||||
|
||||
let title_cn = '';
|
||||
if (type) {
|
||||
title_cn = $(`a[href="http://www.mpaypass.com.cn/${type}.html"]`).text();
|
||||
} else {
|
||||
title_cn = '最新文章';
|
||||
}
|
||||
const list = $('.newslist')
|
||||
.map(function() {
|
||||
const info = {
|
||||
title: $(this)
|
||||
.find('#title')
|
||||
.text(),
|
||||
link: $(this)
|
||||
.find('#pic a')
|
||||
.attr('href'),
|
||||
pic: $(this)
|
||||
.find('#pic img')
|
||||
.attr('src'),
|
||||
time: $(this)
|
||||
.find('#time')
|
||||
.text(),
|
||||
};
|
||||
return info;
|
||||
})
|
||||
.get();
|
||||
|
||||
const out = await Promise.all(
|
||||
list.map(async (info) => {
|
||||
const title = info.title;
|
||||
let date = info.time.toString();
|
||||
date = date.substring(2, date.length);
|
||||
const link = info.link;
|
||||
|
||||
const cache = await ctx.cache.get(link);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
|
||||
const response = await axios.get(link);
|
||||
const $ = cheerio.load(response.data);
|
||||
const newsbody = $('div.newsbody').html();
|
||||
|
||||
const single = {
|
||||
title: title,
|
||||
link: link,
|
||||
pubDate: date,
|
||||
description: newsbody,
|
||||
};
|
||||
|
||||
ctx.cache.set(link, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `移动支付网-${title_cn}`,
|
||||
link: title_url,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user