Skip to content

Commit

Permalink
feat(route): add 人民网领导留言板 (#8285)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethan Shen authored Nov 27, 2021
1 parent 713253b commit d1c84c1
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 7 deletions.
22 changes: 15 additions & 7 deletions docs/traditional-media.md
Original file line number Diff line number Diff line change
Expand Up @@ -1036,34 +1036,42 @@ category 对应的关键词有

</Route>

## 人民日报
## 人民网

### 观点

<Route author="LogicJake" example="/people/opinion/223228" path="/people/opinion/:id" :paramsDesc="['板块 id,可在 URL 中找到']"/>
<Route author="LogicJake" example="/people/opinion/223228" path="/people/opinion/:id" :paramsDesc="['板块 id,可在 URL 中找到']"/>

### 环保频道

<Route author="zsimple" example="/people/env/74877" path="/people/env/:id" :paramsDesc="['板块 id,可在 URL 中找到']"/>
<Route author="zsimple" example="/people/env/74877" path="/people/env/:id" :paramsDesc="['板块 id,可在 URL 中找到']"/>

### 习近平系列重要讲话

<Route author="LogicJake" example="/people/xjpjh" path="/people/xjpjh/:keyword?/:year?" :paramsDesc="['关键词,默认不填','年份,默认 all']"/>
<Route author="LogicJake" example="/people/xjpjh" path="/people/xjpjh/:keyword?/:year?" :paramsDesc="['关键词,默认不填','年份,默认 all']"/>

### 中国共产党新闻网 24 小时滚动新闻

<Route author="nczitzk" example="/people/cpc/24h" path="/people/cpc/24h"/>

## 人民日报社 国际金融报

### 栏目
### 国际金融报栏目

<Route author="Origami404" example="/ifnews/48" path="/ifnews/:cid" :paramsDesc="['栏目 ID']">

`cid`可在对应栏目的 url 后的参数中获取,如`热点快报`的栏目 url 为`http://www.ifnews.com/column.html?cid=48`, `cid`即为`48`.

</Route>

### 领导留言板

<Route author="nczitzk" example="/people/liuyan/539" path="/people/liuyan/:id/:state?" :paramsDesc="['编号,可在对应人物页 URL 中找到', '状态,见下表,默认为全部']">

| 全部 | 待回复 | 办理中 | 已办理 |
| ---- | ------ | ------ | ------ |
| 1 | 2 | 3 | 4 |

</Route>

## 日本経済新聞

### ホームページ
Expand Down
54 changes: 54 additions & 0 deletions lib/v2/people/liuyan.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');

module.exports = async (ctx) => {
const fid = ctx.params.id;
const state = ctx.params.state ?? '1';

const rootUrl = 'http://liuyan.people.com.cn';
const currentUrl = `${rootUrl}/threads/list?fid=${fid}#state=${state}`;

let currentForum;

const apiResponse = await got({
method: 'post',
url: `${rootUrl}/threads/queryThreadsList`,
form: {
fid,
state,
lastItem: 0,
},
});

const list = apiResponse.data.responseData.map((item) => ({
title: item.subject,
author: item.nickName,
link: `${rootUrl}/threads/content?tid=${item.tid}`,
pubDate: parseDate(item.threadsCheckTime * 1000),
}));

const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
});

const content = cheerio.load(detailResponse.data);

item.description = content('.content').html();
currentForum = currentForum ?? content('#currentForum').text();

return item;
})
)
);

ctx.state.data = {
title: `${currentForum} - 领导留言板 - 人民网`,
link: currentUrl,
item: items,
};
};
3 changes: 3 additions & 0 deletions lib/v2/people/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/liuyan/:id/:state?': ['nczitzk'],
};
13 changes: 13 additions & 0 deletions lib/v2/people/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
'people.com': {
_name: '人民网',
liuyan: [
{
title: '领导留言板',
docs: 'https://docs.rsshub.app/traditional-media.html#ren-min-wang-ling-dao-liu-yan-ban',
source: '/',
target: '/people/liuyan/:id/:state?',
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/people/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/liuyan/:id/:state?', require('./liuyan'));
};

0 comments on commit d1c84c1

Please sign in to comment.