feat(route): cde zdyz (#10171)

This commit is contained in:
Tony 2022-07-08 01:15:49 +09:00 committed by GitHub
parent 95bd65111c
commit 87485ec9b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 101 additions and 0 deletions

View File

@ -265,6 +265,16 @@ pageClass: routes
</Route>
### 指导原则专栏
<Route author="TonyRL" example="/cde/zdyz/domesticGuide" path="/cde/zdyz/:category" :paramsDesc="['类别,见下表']" radar="1" rssbud="1">
| 发布通告 | 征求意见 |
| :-----------: | :---------: |
| domesticGuide | opinionList |
</Route>
## 国家自然科学基金委员会
### 基金要闻

View File

@ -1,4 +1,5 @@
module.exports = {
'/xxgk/:category': ['TonyRL'],
'/zdyz/:category': ['TonyRL'],
'/:channel/:category': ['Fatpandac'],
};

View File

@ -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',
},
],
},
};

View File

@ -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'));
};

77
lib/v2/cde/zdyz.js Normal file
View File

@ -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,
};
};