rss:add infzm news (#172)
This commit is contained in:
parent
c33c990977
commit
677b4000ff
|
|
@ -101,6 +101,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
|
|||
* 频道
|
||||
* 爱奇艺
|
||||
* 动漫
|
||||
* 南方周末
|
||||
* 新闻
|
||||
|
||||
## 参与我们
|
||||
|
||||
|
|
|
|||
|
|
@ -769,3 +769,17 @@ key: 产品密钥
|
|||
路由: `/iqiyi/dongman/:id`
|
||||
|
||||
参数: id,动漫 id,可在该动漫主页 URL 中找到(不包括`.html`)
|
||||
|
||||
##南方周末
|
||||
|
||||
### 新闻分类
|
||||
|
||||
举例:[https://rsshub.app/infzm/5](https://rsshub.app/infzm/5)
|
||||
|
||||
路由: `/infzm/:id`
|
||||
|
||||
参数: id,南方周末内容分区 id,可在该内容分区的 URL 中找到(即http://www.infzm.com/contents/:id),注意 contents 为内容分区,content 为文章页,添加前请留意。下面给出部分参考:
|
||||
|
||||
| 全站 | 新闻 | 经济 | 文化 | 评论 | 图片 | 生活 | 时政 | 社会 | 科技 | 绿色 | 头条 |
|
||||
| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |
|
||||
| 0 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 1374 | 2553 |
|
||||
|
|
|
|||
|
|
@ -205,4 +205,7 @@ router.get('/geektime/column/:cid', require('./routes/geektime/column'));
|
|||
// 爱奇艺
|
||||
router.get('/iqiyi/dongman/:id', require('./routes/iqiyi/dongman'));
|
||||
|
||||
// infzm
|
||||
router.get('/infzm/:id', require('./routes/infzm/news'));
|
||||
|
||||
module.exports = router;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
const axios = require('../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
const config = require('../../config');
|
||||
|
||||
const baseUrl = 'http://www.infzm.com/contents/';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id;
|
||||
const url = `${baseUrl}${id}`;
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: url,
|
||||
headers: {
|
||||
'User-Agent': config.ua,
|
||||
Referer: url,
|
||||
},
|
||||
});
|
||||
|
||||
const data = response.data;
|
||||
const $ = cheerio.load(data);
|
||||
const list = $('article');
|
||||
ctx.state.data = {
|
||||
title: `${$('title').text()}-${$('#sortName')
|
||||
.find('a')
|
||||
.text()}`,
|
||||
link: url,
|
||||
description: $('meta[name="description"]').attr('content'),
|
||||
item:
|
||||
list &&
|
||||
list
|
||||
.map((item, index) => {
|
||||
item = $(index);
|
||||
const info = item
|
||||
.find('div.clearfix>div>p.articleInfo')
|
||||
.text()
|
||||
.trim()
|
||||
.split(/\s+/);
|
||||
const date = new Date(`${info.slice(-2)[0]}T${info.slice(-1)[0]}`);
|
||||
return {
|
||||
title: item.find('div.articleTitle>h>a').text(),
|
||||
description: `${item.find('div.clearfix>div>p.intro').text()}<img referrerpolicy="no-referrer" src="${item.find('img').attr('src')}">`,
|
||||
pubDate: date.toUTCString(),
|
||||
link: item.find('a').attr('href'),
|
||||
};
|
||||
})
|
||||
.get(),
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue