feat(route): add 中华人民共和国交通运输部 (#13886)

* feat(route): add 中华人民共和国交通运输部

* fix: url redirect

---------
This commit is contained in:
Ethan Shen
2023-11-26 01:48:14 +08:00
committed by GitHub
parent 2272f7d42d
commit ffaca71061
5 changed files with 277 additions and 0 deletions
+1
View File
@@ -35,6 +35,7 @@ module.exports = {
'/moe/s78/:column': ['TonyRL'],
'/mofcom/article/:suffix+': ['LogicJake'],
'/moj/aac/news/:type?': ['TonyRL'],
'/mot/:category?': ['nczitzk'],
'/news/:uid': ['EsuRt'],
'/nifdc/:path+': ['nczitzk'],
'/nmpa/:path+': ['TonyRL'],
+66
View File
@@ -0,0 +1,66 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const timezone = require('@/utils/timezone');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const { category = 'tongjishuju/gonglu' } = ctx.params;
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 30;
const rootUrl = 'https://www.mot.gov.cn';
const currentUrl = new URL(`${category}/`, rootUrl).href;
const { data: response } = await got(currentUrl);
const $ = cheerio.load(response);
let items = $('div.tab-pane a[title]')
.slice(0, limit)
.toArray()
.map((item) => {
item = $(item);
const link = item.prop('href');
return {
title: item.prop('title'),
link: link.startsWith('http') ? link : new URL(item.prop('href'), currentUrl).href,
pubDate: parseDate(item.find('span.badge').text()),
};
});
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
if (/\.gov\.cn/.test(item.link)) {
const { data: detailResponse } = await got(item.link);
const content = cheerio.load(detailResponse);
item.title = content('meta[name="ArticleTitle"]').prop('content') || content('h1#ti').text();
item.description = content('div.TRS_UEDITOR').html();
item.author = [...new Set([content('meta[name="Author"]').prop('content'), content('meta[name="ContentSource"]').prop('content')])].filter((a) => a);
item.category = [
...new Set([content('meta[name="ColumnName"]').prop('content'), content('meta[name="ColumnType"]').prop('content'), ...(content('meta[name="Keywords"]').prop('content')?.split(/,|;/) ?? [])]),
].filter((c) => c);
item.pubDate = timezone(parseDate(content('meta[name="PubDate"]').prop('content')), +8);
}
return item;
})
)
);
const image = new URL($('a.navbar-brand img').prop('src'), rootUrl).href;
ctx.state.data = {
item: items,
title: $('title').text(),
link: currentUrl,
description: $('meta[name="ColumnDescription"]').prop('content'),
language: $('html').prop('lang'),
image,
subtitle: $('meta[name="ColumnName"]').prop('content'),
author: $('meta[name="SiteName"]').prop('content'),
};
};
+153
View File
@@ -884,6 +884,159 @@ module.exports = {
},
],
},
'mot.gov.cn': {
_name: '中华人民共和国交通运输部',
'.': [
{
title: '栏目',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-jiao-tong-yun-shu-bu-lan-mu',
source: ['/:category*'],
target: (params) => {
const category = params.category;
return `/gov/mot${category ? `/${category}` : ''}`;
},
},
{
title: '时政要闻',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-jiao-tong-yun-shu-bu-lan-mu',
source: ['/shizhengyaowen'],
target: '/gov/mot/shizhengyaowen',
},
{
title: '交通要闻',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-jiao-tong-yun-shu-bu-lan-mu',
source: ['/jiaotongyaowen'],
target: '/gov/mot/jiaotongyaowen',
},
{
title: '重要会议',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-jiao-tong-yun-shu-bu-lan-mu',
source: ['/zhongyaohuiyi'],
target: '/gov/mot/zhongyaohuiyi',
},
{
title: '数据开放',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-jiao-tong-yun-shu-bu-lan-mu',
source: ['/sjkf'],
target: '/gov/mot/sjkf',
},
{
title: '统计数据',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-jiao-tong-yun-shu-bu-lan-mu',
source: ['/tongjishuju'],
target: '/gov/mot/tongjishuju',
},
{
title: '分析公报',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-jiao-tong-yun-shu-bu-lan-mu',
source: ['/fenxigongbao'],
target: '/gov/mot/fenxigongbao',
},
{
title: '运价指数',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-jiao-tong-yun-shu-bu-lan-mu',
source: ['/yunjiazhishu'],
target: '/gov/mot/yunjiazhishu',
},
{
title: '公路',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-jiao-tong-yun-shu-bu-lan-mu',
source: ['/tongjishuju/gonglu'],
target: '/gov/mot/tongjishuju/gonglu',
},
{
title: '水运',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-jiao-tong-yun-shu-bu-lan-mu',
source: ['/tongjishuju/shuiyun'],
target: '/gov/mot/tongjishuju/shuiyun',
},
{
title: '铁路',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-jiao-tong-yun-shu-bu-lan-mu',
source: ['/tongjishuju/tielu'],
target: '/gov/mot/tongjishuju/tielu',
},
{
title: '民航',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-jiao-tong-yun-shu-bu-lan-mu',
source: ['/tongjishuju/minhang'],
target: '/gov/mot/tongjishuju/minhang',
},
{
title: '邮政',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-jiao-tong-yun-shu-bu-lan-mu',
source: ['/tongjishuju/youzheng'],
target: '/gov/mot/tongjishuju/youzheng',
},
{
title: '城市客运',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-jiao-tong-yun-shu-bu-lan-mu',
source: ['/tongjishuju/chengshikeyun'],
target: '/gov/mot/tongjishuju/chengshikeyun',
},
{
title: '港口货物旅客吞吐量',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-jiao-tong-yun-shu-bu-lan-mu',
source: ['/tongjishuju/gangkouhuowulvkettl'],
target: '/gov/mot/tongjishuju/gangkouhuowulvkettl',
},
{
title: '固定资产投资完成情况',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-jiao-tong-yun-shu-bu-lan-mu',
source: ['/tongjishuju/gudingzichantouziwcqk'],
target: '/gov/mot/tongjishuju/gudingzichantouziwcqk',
},
{
title: '行业公报',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-jiao-tong-yun-shu-bu-lan-mu',
source: ['/fenxigongbao/hangyegongbao'],
target: '/gov/mot/fenxigongbao/hangyegongbao',
},
{
title: '经济分析',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-jiao-tong-yun-shu-bu-lan-mu',
source: ['/fenxigongbao/jingjifenxi'],
target: '/gov/mot/fenxigongbao/jingjifenxi',
},
{
title: '科技统计',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-jiao-tong-yun-shu-bu-lan-mu',
source: ['/fenxigongbao/kejitongji'],
target: '/gov/mot/fenxigongbao/kejitongji',
},
{
title: '运力分析',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-jiao-tong-yun-shu-bu-lan-mu',
source: ['/fenxigongbao/yunlifenxi'],
target: '/gov/mot/fenxigongbao/yunlifenxi',
},
{
title: '沿海散货运价指数',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-jiao-tong-yun-shu-bu-lan-mu',
source: ['/yunjiazhishu/yanhaisanhuoyjzs'],
target: '/gov/mot/yunjiazhishu/yanhaisanhuoyjzs',
},
{
title: '出口集装箱运价指数',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-jiao-tong-yun-shu-bu-lan-mu',
source: ['/yunjiazhishu/chukoujizhuangxiangyjzs'],
target: '/gov/mot/yunjiazhishu/chukoujizhuangxiangyjzs',
},
{
title: '长江航运指数分析',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-jiao-tong-yun-shu-bu-lan-mu',
source: ['/yunjiazhishu/changjianghangyunzsfx'],
target: '/gov/mot/yunjiazhishu/changjianghangyunzsfx',
},
{
title: '珠江水运经济运行分析',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-jiao-tong-yun-shu-bu-lan-mu',
source: ['/yunjiazhishu/zhujiangshuiyunjjyxfx'],
target: '/gov/mot/yunjiazhishu/zhujiangshuiyunjjyxfx',
},
],
},
'mztoday.gov.cn': {
_name: '德阳市人民政府',
www: [
+1
View File
@@ -16,6 +16,7 @@ module.exports = function (router) {
router.get('/mee/ywdt/:category?', require('./mee/ywdt'));
router.get('/mem/gk/sgcc/:category?', require('./mem/sgcc'));
router.get('/mfa/wjdt/:category?', require('./mfa/wjdt'));
router.get('/mot/:category*', require('./mot'));
router.get('/miit/wjfb/:ministry', require('./miit/wjfb'));
router.get('/miit/yjzj', require('./miit/yjzj'));
router.get('/miit/zcwj', require('./miit/zcwj'));
+56
View File
@@ -1787,6 +1787,62 @@ Language
</Route>
## 中华人民共和国交通运输部 {#zhong-hua-ren-min-gong-he-guo-jiao-tong-yun-shu-bu}
### 栏目 {#zhong-hua-ren-min-gong-he-guo-jiao-tong-yun-shu-bu-lan-mu}
<Route author="nczitzk" example="/gov/mot/jiaotongyaowen" path="/gov/mot/:category?" paramsDesc={['分类 id,见下表,默认为交通要闻']} radar="1" rssbud="1">
#### 新闻 {#zhong-hua-ren-min-gong-he-guo-jiao-tong-yun-shu-bu-lan-mu-xin-wen}
| 分类名 | 分类 id |
| -------- | -------------- |
| 时政要闻 | shizhengyaowen |
| 交通要闻 | jiaotongyaowen |
| 重要会议 | zhongyaohuiyi |
#### 数据 {#zhong-hua-ren-min-gong-he-guo-jiao-tong-yun-shu-bu-lan-mu-shu-ju}
| 分类名 | 分类 id |
| -------- | ------------ |
| 数据开放 | sjkf |
| 统计数据 | tongjishuju |
| 分析公报 | fenxigongbao |
| 运价指数 | yunjiazhishu |
#### 统计数据 {#zhong-hua-ren-min-gong-he-guo-jiao-tong-yun-shu-bu-lan-mu-tong-ji-shu-ju}
| 分类名 | 分类 id |
| -------------------- | --------------------------------- |
| 公路 | tongjishuju/gonglu |
| 水运 | tongjishuju/shuiyun |
| 铁路 | tongjishuju/tielu |
| 民航 | tongjishuju/minhang |
| 邮政 | tongjishuju/youzheng |
| 城市客运 | tongjishuju/chengshikeyun |
| 港口货物旅客吞吐量 | tongjishuju/gangkouhuowulvkettl |
| 固定资产投资完成情况 | tongjishuju/gudingzichantouziwcqk |
#### 分析公报 {#zhong-hua-ren-min-gong-he-guo-jiao-tong-yun-shu-bu-lan-mu-fen-xi-gong-bao}
| 分类名 | 分类 id |
| -------- | -------------------------- |
| 行业公报 | fenxigongbao/hangyegongbao |
| 经济分析 | fenxigongbao/jingjifenxi |
| 科技统计 | fenxigongbao/kejitongji |
| 运力分析 | fenxigongbao/yunlifenxi |
#### 运价指数 {#zhong-hua-ren-min-gong-he-guo-jiao-tong-yun-shu-bu-lan-mu-yun-jia-zhi-shu}
| 分类名 | 分类 id |
| -------------------- | ------------------------------------ |
| 沿海散货运价指数 | yunjiazhishu/yanhaisanhuoyjzs |
| 出口集装箱运价指数 | yunjiazhishu/chukoujizhuangxiangyjzs |
| 长江航运指数分析 | yunjiazhishu/changjianghangyunzsfx |
| 珠江水运经济运行分析 | yunjiazhishu/zhujiangshuiyunjjyxfx |
</Route>
## 中华人民共和国教育部 {#zhong-hua-ren-min-gong-he-guo-jiao-yu-bu}
### 新闻 {#zhong-hua-ren-min-gong-he-guo-jiao-yu-bu-xin-wen}