Add(route): add 国家药品审评网站 (#8910)

This commit is contained in:
Fatpandac
2022-01-22 12:04:06 +00:00
committed by GitHub
parent 8dcb3f53e3
commit c0229da7da
6 changed files with 225 additions and 0 deletions
+24
View File
@@ -127,6 +127,30 @@ pageClass: routes
<Route author="y2361547758" example="/gov/nppa/318/45948" path="/gov/nppa/:channel/:content" :paramsDesc="['栏目名id', '文章id']" radar="1" rssbud="1"/>
## 国家药品审评网站
### 首页
<Route author="Fatpandac" example="/cde/news/gzdt" path="/cde/:channel/:category" :paramsDesc="['频道', '类别']">
- 频道
| 新闻中心 | 政策法规 |
| :------: | :------: |
| news | policy |
- 类别
| 新闻中心 | 政务新闻 | 要闻导读 | 图片新闻 | 工作动态 |
| :------: | :------: | :------: | :------: | :------: |
| | zwxw | ywdd | tpxw | gzdt |
| 政策法规 | 法律法规 | 中心规章 |
| :------: | :------: | :------: |
| | flfg | zxgz |
</Route>
## 哈尔滨市科技局
### 政务公开
+132
View File
@@ -0,0 +1,132 @@
const utils = require('./utils');
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const channelLinkMap = {
news: 'https://www.cde.org.cn/main/news/listpage/545cf855a50574699b46b26bcb165f32',
policy: 'https://www.cde.org.cn/main/policy/listpage/9f9c74c73e0f8f56a8bfbc646055026d',
};
const cateUrlMap = {
news: {
zwxw: 'getList',
ywdd: 'getHotNewsList',
tpxw: 'getPictureNewsList',
gzdt: 'getWorkList',
},
policy: {
flfg: 'getPolicyList',
zxgz: 'getRuleList',
},
};
const cateTitleMap = {
news: {
zwxw: '政务新闻',
ywdd: '要闻导读',
tpxw: '图片新闻',
gzdt: '工作动态',
},
policy: {
flfg: '法律法规',
zxgz: '政策规章',
},
};
const requestData = {
news: {
zwxw: {
pageSize: 25,
pageNum: 1,
classId: '545cf855a50574699b46b26bcb165f32',
},
ywdd: {
pageSize: 25,
pageNum: 1,
ishot: 1,
},
tpxw: {
pageSize: 25,
pageNum: 1,
},
gzdt: {
pageSize: 25,
pageNum: 1,
classId: '8dc6aac86eb083759b1e01615617a347',
},
},
policy: {
flfg: {
pageNum: 1,
pageSize: 25,
fclass: 0,
keyName: 'TITLE',
logicC: 'bh',
},
zxgz: {
pageNum: 1,
pageSize: 25,
fclass: 0,
keyName: 'TITLE',
logicC: 'bh',
},
},
};
module.exports = async (ctx) => {
const channel = ctx.params.channel;
const cate = ctx.params.category;
requestData[channel][cate].pageSize = ctx.params.limit ?? 25;
const url = `${utils.rootUrl}/main/${channel}/${cateUrlMap[channel][cate]}`;
const response = await got({
method: 'post',
url,
headers: {
cookie: await utils.getCookie(ctx),
},
form: requestData[channel][cate],
});
const data = response.data.data;
const list = data.records.map((item) => {
const linkMap = {
news: `${utils.rootUrl}/main/${item.isPic ? 'newspic/view/' : 'news/viewInfoCommon/'}${item.newsIdCode}`,
policy: `${utils.rootUrl}/main/${item.regulatIdCODE ? `policy/regulatview/${item.regulatIdCODE}` : `policy/view/${item.policyIdCODE}`}`,
};
return {
title: item.title,
link: linkMap[channel],
};
});
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got.get(item.link, {
headers: {
cookie: await utils.getCookie(ctx),
},
});
const $ = cheerio.load(detailResponse.data);
item.pubDate = parseDate($('div.news_detail_date').text(), 'YYYYMMDD');
const desc = $('div.news_detail_box');
const removeTitle = desc.find('div.news_detail_title').remove().end();
const removeDate = removeTitle.find('div.news_detail_date').remove().end();
const removeImage = removeDate.find('img').remove().end();
item.description = removeImage.html();
return item;
})
)
);
ctx.state.data = {
title: `${utils.title} - ${cateTitleMap[channel][cate]}`,
link: String(channelLinkMap[channel]),
item: items,
};
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
'/:channel/:category': ['Fatpandac'],
};
+43
View File
@@ -0,0 +1,43 @@
module.exports = {
'cde.org.cn': {
_name: '国家药品监督管理局药品审评中心',
www: [
{
title: '政务新闻',
docs: 'https://docs.rsshub.app/government.html#guo-jia-yao-pin-shen-ping-wang-zhan-shou-ye',
source: ['/main/news/listpage/545cf855a50574699b46b26bcb165f32'],
target: '/cde/news/zwxw',
},
{
title: '要闻导读',
docs: 'https://docs.rsshub.app/government.html#guo-jia-yao-pin-shen-ping-wang-zhan-shou-ye',
source: ['/main/news/listpage/545cf855a50574699b46b26bcb165f32'],
target: '/cde/news/ywdd',
},
{
title: '图片新闻',
docs: 'https://docs.rsshub.app/government.html#guo-jia-yao-pin-shen-ping-wang-zhan-shou-ye',
source: ['/main/news/listpage/545cf855a50574699b46b26bcb165f32'],
target: '/cde/news/tpxw',
},
{
title: '工作动态',
docs: 'https://docs.rsshub.app/government.html#guo-jia-yao-pin-shen-ping-wang-zhan-shou-ye',
source: ['/main/news/listpage/545cf855a50574699b46b26bcb165f32'],
target: '/cde/news/gzdt',
},
{
title: '法律法规',
docs: 'https://docs.rsshub.app/government.html#guo-jia-yao-pin-shen-ping-wang-zhan-shou-ye',
source: ['/main/policy/listpage/9f9c74c73e0f8f56a8bfbc646055026d'],
target: '/cde/policy/flfg',
},
{
title: '中心规章',
docs: 'https://docs.rsshub.app/government.html#guo-jia-yao-pin-shen-ping-wang-zhan-shou-ye',
source: ['/main/policy/listpage/9f9c74c73e0f8f56a8bfbc646055026d'],
target: '/cde/policy/zxgz',
},
],
},
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/:channel/:category', require('./index'));
};
+20
View File
@@ -0,0 +1,20 @@
const got = require('@/utils/got');
const title = '国家药品监督管理局药品审评中心';
const rootUrl = 'https://www.cde.org.cn';
const getCookie = (ctx) =>
ctx.cache.tryGet(rootUrl, async () => {
const response = await got.get(rootUrl);
return response.headers['set-cookie']
.join()
.match(/FSSBBIl1UgzbN7N80.*?;/g)
.join('');
});
module.exports = {
title,
rootUrl,
getCookie,
};