forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
RANPOX
authored and
DIYgod
committed
May 21, 2018
1 parent
c33c990
commit 677b400
Showing
4 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,6 +101,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇 | |
* 频道 | ||
* 爱奇艺 | ||
* 动漫 | ||
* 南方周末 | ||
* 新闻 | ||
|
||
## 参与我们 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(), | ||
}; | ||
}; |