feat(route): add 中国载人航天 (#10355)

* feat(route): add 中国载人航天

* docs: add category for /fxrw

* update lib/v2/gov/cmse/index.js

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* docs: add xwzt
This commit is contained in:
Ethan Shen 2022-08-03 01:27:19 +08:00 committed by GitHub
parent c41de8ee47
commit e761af6c86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 271 additions and 0 deletions

View File

@ -758,6 +758,82 @@ pageClass: routes
</Route>
## 中国载人航天
### 综合新闻
<Route author="nczitzk" example="/gov/cmse/xwzx/zhxw" path="/gov/cmse/xwzx/zhxw" />
### 研制进展
<Route author="nczitzk" example="/gov/cmse/xwzx/yzjz" path="/gov/cmse/xwzx/yzjz" />
### 官方公告
<Route author="nczitzk" example="/gov/cmse/gfgg" path="/gov/cmse/gfgg" />
### 飞行任务
<Route author="nczitzk" example="/gov/cmse/fxrw" path="/gov/cmse/fxrw" />
### 任务动态
<Route author="nczitzk" example="/gov/cmse/fxrw/wtfx/rwdt" path="/gov/cmse/fxrw/:id/:category" :paramsDesc="['任务 id可在对应任务页 URL 中找到', '分类 id见下表可在对应任务页 URL 中找到']">
::: tip 提示
下表分类可能并不完整。请查看各飞行任务详情页获得完整分类。
:::
| 任务动态 | 综合新闻 | 视频 | 图片新闻 | 媒体聚焦 |
| ---- | ---- | -- | ---- | ---- |
| rwdt | zhxw | sp | tpxw | mtjj |
</Route>
### 空间科学
<Route author="nczitzk" example="/gov/cmse/kjkx/kjkxyjyyy" path="/gov/cmse/kjkx/:id" :paramsDesc="['分类 id见下表可在对应分类页 URL 中找到']">
| 空间科学研究与应用 | 航天技术试验 | 航天医学实验 |
| --------- | ------ | ------ |
| kjkxyjyyy | htjssy | htyxsy |
### 国际合作
<Route author="nczitzk" example="/gov/cmse/gjhz" path="/gov/cmse/gjhz" />
### 环球视野
<Route author="nczitzk" example="/gov/cmse/hqsy/zxdta" path="/gov/cmse/hqsy/:id" :paramsDesc="['分类 id见下表可在对应分类页 URL 中找到']">
| 最新动态 | 美国 | 俄罗斯 | 欧洲 | 日本 | 印度 | 领域动态 |
| ----- | -- | --- | -- | -- | -- | ---- |
| zxdta | mg | els | oz | rb | yd | lydt |
</Route>
### 专题报道
<Route author="nczitzk" example="/gov/cmse/ztbd/xwfbh" path="/gov/cmse/ztbd/:id" :paramsDesc="['分类 id见下表可在对应分类页 URL 中找到']">
| 新闻发布会 | 学术大会 | 标准 | 新闻专题 |
| ----- | ---- | -- | ---- |
| xwfdh | xsdh | bz | xwzt |
</Route>
### 科普教育
<Route author="nczitzk" example="/gov/cmse/kpjy/kphd" path="/gov/cmse/kpjy/:id" :paramsDesc="['分类 id见下表可在对应分类页 URL 中找到']">
| 科普活动 | 太空课堂 | 航天知识 |
| ---- | ---- | ---- |
| kphd | tkkt | ttzs |
</Route>
## 中国证券监督管理委员会
### 发审委公告

40
lib/v2/gov/cmse/fxrw.js Normal file
View File

@ -0,0 +1,40 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const timezone = require('@/utils/timezone');
const { parseDate } = require('@/utils/parse-date');
const { art } = require('@/utils/render');
const path = require('path');
module.exports = async (ctx) => {
const rootUrl = 'http://www.cmse.gov.cn';
const currentUrl = `${rootUrl}/fxrw/`;
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
const items = $('#list li a')
.toArray()
.map((item) => {
item = $(item);
return {
title: item.find('.title').text().split('').pop().trim(),
link: new URL(item.attr('href'), currentUrl),
pubDate: timezone(parseDate(item.find('.infoR').first().text().trim(), 'YYYY年M月D日H时m分'), +8),
description: art(path.join(__dirname, 'templates/description.art'), {
image: item.find('img').attr('src'),
description: item.find('.info').html(),
}),
};
});
ctx.state.data = {
title: $('title').text(),
link: currentUrl,
item: items,
};
};

67
lib/v2/gov/cmse/index.js Normal file
View File

@ -0,0 +1,67 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const timezone = require('@/utils/timezone');
const { parseDate } = require('@/utils/parse-date');
const { art } = require('@/utils/render');
const path = require('path');
module.exports = async (ctx) => {
ctx.path = ctx.path.replace(/(^\/cmse|\/$)/g, '');
const rootUrl = 'http://www.cmse.gov.cn';
const currentUrl = `${rootUrl}${ctx.path === '' ? '/xwzx/zhxw/' : `${ctx.path}/`}`;
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
let items = $('#list li a')
.slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 15)
.toArray()
.map((item) => {
item = $(item);
const pubDate = item.next().text();
const link = new URL(item.attr('href'), currentUrl).href;
return {
title: item.text(),
pubDate: parseDate(pubDate),
link: /\.html$/.test(link) ? link : `${link}#${pubDate}`,
};
});
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
});
const content = cheerio.load(detailResponse.data);
content('.share').remove();
const detailPubTimeMatches = detailResponse.data.match(/__\$pubtime='(.*?)';var/);
item.pubDate = detailPubTimeMatches ? timezone(parseDate(detailPubTimeMatches[1]), +8) : item.pubDate;
item.description = art(path.join(__dirname, 'templates/description.art'), {
video: content('#con_video').html(),
description: content('.TRS_Editor, #content').html(),
});
return item;
})
)
);
ctx.state.data = {
title: $('title').text(),
link: currentUrl,
item: items,
};
};

View File

@ -0,0 +1,11 @@
{{ if image }}
<img src="{{ image }}">
<br>
{{ /if }}
{{ if video }}
{{@ video }}
<br>
{{ /if }}
{{ if description }}
{{@ description }}
{{ /if }}

View File

@ -1,5 +1,15 @@
module.exports = {
// ministry
'/cmse/xwzx/zhxw': ['nczitzk'],
'/cmse/xwzx/yzjz': ['nczitzk'],
'/cmse/gfgg': ['nczitzk'],
'/cmse/fxrw': ['nczitzk'],
'/cmse/kjkx/:id': ['nczitzk'],
'/cmse/gjhz': ['nczitzk'],
'/cmse/hqsy/:id': ['nczitzk'],
'/cmse/ztbd/:id': ['nczitzk'],
'/cmse/kpjy/:id': ['nczitzk'],
'/cmse/:path+': ['nczitzk'],
'/customs/list/:gchannel?': ['Jeason0228', 'TonyRL'],
'/fmprc/:category?': ['nicolaszf', 'nczitzk'],
'/immiau/news': ['liu233w'],

View File

@ -297,6 +297,71 @@ module.exports = {
},
],
},
'cmse.gov.cn': {
_name: '中国载人航天',
www: [
{
title: '综合新闻',
docs: 'https://docs.rsshub.app/government.html#zhong-guo-zai-ren-hang-tian',
source: ['/xwzx/zhxw'],
target: '/gov/cmse/xwzx/zhxw',
},
{
title: '研制进展',
docs: 'https://docs.rsshub.app/government.html#zhong-guo-zai-ren-hang-tian',
source: ['/xwzx/yzjz'],
target: '/gov/cmse/xwzx/yzjz',
},
{
title: '官方公告',
docs: 'https://docs.rsshub.app/government.html#zhong-guo-zai-ren-hang-tian',
source: ['/gfgg'],
target: '/gov/cmse/gfgg',
},
{
title: '飞行任务',
docs: 'https://docs.rsshub.app/government.html#zhong-guo-zai-ren-hang-tian',
source: ['/fxrw'],
target: '/gov/cmse/fxrw',
},
{
title: '任务动态',
docs: 'https://docs.rsshub.app/government.html#zhong-guo-zai-ren-hang-tian',
source: ['/fxrw/:id/:category'],
target: '/gov/cmse/fxrw/:id/:category',
},
{
title: '空间科学',
docs: 'https://docs.rsshub.app/government.html#zhong-guo-zai-ren-hang-tian',
source: ['/kjkx/:id'],
target: '/gov/cmse/kjkx/:id',
},
{
title: '国际合作',
docs: 'https://docs.rsshub.app/government.html#zhong-guo-zai-ren-hang-tian',
source: ['/gjhz'],
target: '/gov/cmse/gjhz',
},
{
title: '环球视野',
docs: 'https://docs.rsshub.app/government.html#zhong-guo-zai-ren-hang-tian',
source: ['/hqsy/:id'],
target: '/gov/cmse/hqsy/:id',
},
{
title: '专题报道',
docs: 'https://docs.rsshub.app/government.html#zhong-guo-zai-ren-hang-tian',
source: ['/ztbd/:id'],
target: '/gov/cmse/ztbd/:id',
},
{
title: '科普教育',
docs: 'https://docs.rsshub.app/government.html#zhong-guo-zai-ren-hang-tian',
source: ['/kpjy/:id'],
target: '/gov/cmse/kpjy/:id',
},
],
},
'customs.gov.cn': {
_name: '中华人民共和国海关总署',
www: [

View File

@ -1,5 +1,7 @@
module.exports = function (router) {
// ministry
router.get('/cmse/fxrw', require('./cmse/fxrw'));
router.get(/cmse(\/[\w/-]+)?/, require('./cmse'));
router.get('/customs/list/:gchannel?', require('./customs/list'));
router.get('/fmprc/:category?', require('./mfa/wjdt'));
router.get('/immiau/news', require('./immiau/news'));