From d1c84c154da6dcbc61d45d6498c55df20032f170 Mon Sep 17 00:00:00 2001 From: Ethan Shen Date: Sat, 27 Nov 2021 15:54:10 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20=E4=BA=BA=E6=B0=91?= =?UTF-8?q?=E7=BD=91=E9=A2=86=E5=AF=BC=E7=95=99=E8=A8=80=E6=9D=BF=20(#8285?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/traditional-media.md | 22 ++++++++++----- lib/v2/people/liuyan.js | 54 +++++++++++++++++++++++++++++++++++++ lib/v2/people/maintainer.js | 3 +++ lib/v2/people/radar.js | 13 +++++++++ lib/v2/people/router.js | 3 +++ 5 files changed, 88 insertions(+), 7 deletions(-) create mode 100644 lib/v2/people/liuyan.js create mode 100644 lib/v2/people/maintainer.js create mode 100644 lib/v2/people/radar.js create mode 100644 lib/v2/people/router.js diff --git a/docs/traditional-media.md b/docs/traditional-media.md index 5906899482326e..31242bb4a38ba8 100644 --- a/docs/traditional-media.md +++ b/docs/traditional-media.md @@ -1036,27 +1036,25 @@ category 对应的关键词有 -## 人民日报 +## 人民网 ### 观点 - + ### 环保频道 - + ### 习近平系列重要讲话 - + ### 中国共产党新闻网 24 小时滚动新闻 -## 人民日报社 国际金融报 - -### 栏目 +### 国际金融报栏目 @@ -1064,6 +1062,16 @@ category 对应的关键词有 +### 领导留言板 + + + +| 全部 | 待回复 | 办理中 | 已办理 | +| ---- | ------ | ------ | ------ | +| 1 | 2 | 3 | 4 | + + + ## 日本経済新聞 ### ホームページ diff --git a/lib/v2/people/liuyan.js b/lib/v2/people/liuyan.js new file mode 100644 index 00000000000000..724882a6d515a4 --- /dev/null +++ b/lib/v2/people/liuyan.js @@ -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, + }; +}; diff --git a/lib/v2/people/maintainer.js b/lib/v2/people/maintainer.js new file mode 100644 index 00000000000000..f35aad2e84d483 --- /dev/null +++ b/lib/v2/people/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/liuyan/:id/:state?': ['nczitzk'], +}; diff --git a/lib/v2/people/radar.js b/lib/v2/people/radar.js new file mode 100644 index 00000000000000..523dbbdba901d6 --- /dev/null +++ b/lib/v2/people/radar.js @@ -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?', + }, + ], + }, +}; diff --git a/lib/v2/people/router.js b/lib/v2/people/router.js new file mode 100644 index 00000000000000..d8d814550de90a --- /dev/null +++ b/lib/v2/people/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/liuyan/:id/:state?', require('./liuyan')); +};