diff --git a/docs/government.md b/docs/government.md index 3350ef6c7..9cb0ecc5d 100644 --- a/docs/government.md +++ b/docs/government.md @@ -265,6 +265,16 @@ pageClass: routes +### 指导原则专栏 + + + +| 发布通告 | 征求意见 | +| :-----------: | :---------: | +| domesticGuide | opinionList | + + + ## 国家自然科学基金委员会 ### 基金要闻 diff --git a/lib/v2/cde/maintainer.js b/lib/v2/cde/maintainer.js index 339d48cf0..70b33ae83 100644 --- a/lib/v2/cde/maintainer.js +++ b/lib/v2/cde/maintainer.js @@ -1,4 +1,5 @@ module.exports = { '/xxgk/:category': ['TonyRL'], + '/zdyz/:category': ['TonyRL'], '/:channel/:category': ['Fatpandac'], }; diff --git a/lib/v2/cde/radar.js b/lib/v2/cde/radar.js index ade8d0963..30763a5f3 100644 --- a/lib/v2/cde/radar.js +++ b/lib/v2/cde/radar.js @@ -56,6 +56,18 @@ module.exports = { source: ['/main/xxgk/listpage/4b5255eb0a84820cef4ca3e8b6bbe20c'], target: '/cde/xxgf/cliniCal', }, + { + title: '发布通告 - 指导原则专栏', + docs: 'https://docs.rsshub.app/government.html#guo-jia-yao-pin-shen-ping-wang-zhan-shou-ye', + source: ['/main/xxgk/listpage/2853510d929253719601db17b8a9fd81'], + target: '/cde/zdyz/domesticGuide', + }, + { + title: '征求意见 - 指导原则专栏', + docs: 'https://docs.rsshub.app/government.html#guo-jia-yao-pin-shen-ping-wang-zhan-shou-ye', + source: ['/main/xxgk/listpage/3c49fad55caad7a034c263cfc2b6eb9c'], + target: '/cde/zdyz/opinionList', + }, ], }, }; diff --git a/lib/v2/cde/router.js b/lib/v2/cde/router.js index be1e651ae..2ab16c2dc 100644 --- a/lib/v2/cde/router.js +++ b/lib/v2/cde/router.js @@ -1,4 +1,5 @@ module.exports = function (router) { router.get('/xxgk/:category', require('./xxgk')); + router.get('/zdyz/:category', require('./zdyz')); router.get('/:channel/:category', require('./index')); }; diff --git a/lib/v2/cde/zdyz.js b/lib/v2/cde/zdyz.js new file mode 100644 index 000000000..90bbacd8a --- /dev/null +++ b/lib/v2/cde/zdyz.js @@ -0,0 +1,77 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const utils = require('./utils'); + +const baseUrl = 'https://www.cde.org.cn'; +const zdyzMap = { + zdyz: { + domesticGuide: { + title: '发布通告', + url: `${baseUrl}/zdyz/listpage/2853510d929253719601db17b8a9fd81`, + endPoint: '/zdyz/getDomesticGuideList', + form: { + pageNum: 1, + pageSize: 10, + searchTitle: '', + isFbtg: 1, + classid: '2853510d929253719601db17b8a9fd81', + issueDate1: '', + issueDate2: '', + }, + }, + opinionList: { + title: '征求意见', + url: `${baseUrl}/main/zdyz/listpage/3c49fad55caad7a034c263cfc2b6eb9c`, + endPoint: '/zdyz/getOpinionList', + form: { + pageNum: 1, + pageSize: 10, + searchTitle: '', + issueDate1: '', + issueDate2: '', + fclass: '征求意见', + }, + }, + }, +}; + +module.exports = async (ctx) => { + const { category } = ctx.params; + + const { data } = await got.post(`${baseUrl}${zdyzMap.zdyz[category].endPoint}`, { + form: zdyzMap.zdyz[category].form, + headers: { + referer: zdyzMap.zdyz[category].url, + cookie: await utils.getCookie(ctx), + }, + }); + + const list = data.data.records.map((item) => ({ + title: item.title, + pubDate: parseDate(item.issueDate), + link: item.externalLinks, + })); + + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + const response = await got(item.link, { + headers: { + referer: zdyzMap.zdyz[category].url, + cookie: await utils.getCookie(ctx), + }, + }); + const $ = cheerio.load(response.data); + item.description = $('.new_detail_content').html() + $('.relatedNews').html(); + return item; + }) + ) + ); + + ctx.state.data = { + title: `${zdyzMap.zdyz[category].title} - 国家药品监督管理局药品审评中心`, + link: zdyzMap.zdyz[category].url, + item: items, + }; +};