mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat(route): add 中华人民共和国外交部外交动态 (#9348)
* feat(route): add 中华人民共和国外交部外交动态 * fix: wrong pubDate
This commit is contained in:
+16
-2
@@ -974,9 +974,23 @@ pageClass: routes
|
||||
|
||||
## 中华人民共和国外交部
|
||||
|
||||
### 发言人表态
|
||||
### 外交动态
|
||||
|
||||
<Route author="nicolaszf" example="/gov/fmprc/fyrbt" path="/gov/fmprc/fyrbt"/>
|
||||
<Route author="nczitzk" example="/gov/mfa/wjdt/fyrbt" path="/gov/mfa/wjdt/:category?" :paramsDesc="['分类,见下表,默认为领导人活动']">
|
||||
|
||||
| 分类 | category |
|
||||
| ----- | -------- |
|
||||
| 领导人活动 | gjldrhd |
|
||||
| 外事日程 | wsrc |
|
||||
| 部领导活动 | wjbxw |
|
||||
| 业务动态 | sjxw |
|
||||
| 发言人表态 | fyrbt |
|
||||
| 吹风会 | cfhsl |
|
||||
| 大使任免 | dsrm |
|
||||
| 驻外报道 | zwbd |
|
||||
| 政策解读 | zcjd |
|
||||
|
||||
</Route>
|
||||
|
||||
## 中华人民共和国住房和城乡建设部
|
||||
|
||||
|
||||
+1
-1
@@ -1225,7 +1225,7 @@ router.get('/gov/customs/list/:gchannel', lazyloadRouteHandler('./routes/gov/cus
|
||||
router.get('/gov/moe/:type', lazyloadRouteHandler('./routes/gov/moe/moe'));
|
||||
|
||||
// 中华人民共和国外交部
|
||||
router.get('/gov/fmprc/fyrbt', lazyloadRouteHandler('./routes/gov/fmprc/fyrbt'));
|
||||
// router.get('/gov/fmprc/fyrbt', lazyloadRouteHandler('./routes/gov/fmprc/fyrbt'));
|
||||
|
||||
// 中华人民共和国住房和城乡建设部
|
||||
router.get('/gov/mohurd/policy', lazyloadRouteHandler('./routes/gov/mohurd/policy'));
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const util = require('./utils');
|
||||
|
||||
const host = 'https://www.fmprc.gov.cn/web/wjdt_674879/fyrbt_674889/';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got.get(host, {
|
||||
responseType: 'buffer',
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('.newsBd ul li').get();
|
||||
|
||||
const result = await util.ProcessFeed(list, ctx.cache);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '中华人民共和国外交部-发言人表态',
|
||||
link: host,
|
||||
description: '中华人民共和国外交部-发言人表态',
|
||||
item: result,
|
||||
};
|
||||
};
|
||||
@@ -1,50 +0,0 @@
|
||||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
// 加载文章页
|
||||
async function load(link) {
|
||||
const response = await got.get(link);
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const date = parseDate($('.time').text(), 'YYYY-MM-DD HH:mm');
|
||||
|
||||
const pubDate = timezone(date, +8);
|
||||
|
||||
// 提取内容
|
||||
const description = $('#News_Body_Txt_A').html();
|
||||
|
||||
return { description, pubDate };
|
||||
}
|
||||
|
||||
const ProcessFeed = (list, caches) => {
|
||||
const host = 'https://www.fmprc.gov.cn/web/wjdt_674879/fyrbt_674889/';
|
||||
|
||||
return Promise.all(
|
||||
list.map(async (item) => {
|
||||
const $ = cheerio.load(item);
|
||||
|
||||
const $title = $('a');
|
||||
// 还原相对链接为绝对链接
|
||||
const itemUrl = new URL($title.attr('href'), host);
|
||||
|
||||
// 列表上提取到的信息
|
||||
const single = {
|
||||
title: $.text(),
|
||||
link: itemUrl,
|
||||
};
|
||||
|
||||
// 使用tryGet方法从缓存获取内容。
|
||||
// 当缓存中无法获取到链接内容的时候,则使用load方法加载文章内容。
|
||||
const other = await caches.tryGet(itemUrl, () => load(itemUrl));
|
||||
|
||||
// 合并解析后的结果集作为该篇文章最终的输出结果
|
||||
return { ...single, ...other };
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
ProcessFeed,
|
||||
};
|
||||
@@ -3,10 +3,12 @@ module.exports = {
|
||||
'/shenzhen/hrss/szksy/:caty/:page?': ['zlasd'],
|
||||
'/shenzhen/zzb/:caty/:page?': ['zlasd'],
|
||||
'/shanghai/rsj/ksxm': ['Fatpandac'],
|
||||
'/fmprc/:category?': ['nicolaszf', 'nczitzk'],
|
||||
'/guangdong/tqyb/tfxtq': ['Fatpandac'],
|
||||
'/guangdong/tqyb/sncsyjxh': ['Fatpandac'],
|
||||
'/huizhou/zwgk/:category?': ['Fatpandac'],
|
||||
'/sichuan/deyang/govpulicinfo/:countyName/:institutionName?': ['zytomorrow'],
|
||||
'/mfa/wjdt/:category?': ['nczitzk'],
|
||||
'/miit/wjfb/:ministry': ['Fatpandac'],
|
||||
'/miit/yjzj': ['Fatpandac'],
|
||||
'/miit/zcwj': ['Yoge-Code'],
|
||||
|
||||
@@ -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 categories = {
|
||||
gjldrhd: 'gjldrhd_674881',
|
||||
wsrc: 'wsrc_674883',
|
||||
wjbxw: 'wjbxw_674885',
|
||||
sjxw: 'sjxw_674887',
|
||||
fyrbt: 'fyrbt_674889',
|
||||
cfhsl: 'cfhsl_674891',
|
||||
dsrm: 'dsrm_674893',
|
||||
zwbd: 'zwbd_674895',
|
||||
zcjd: 'zcjd',
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category ?? 'gjldrhd';
|
||||
|
||||
const rootUrl = 'https://www.mfa.gov.cn';
|
||||
const currentUrl = `${rootUrl}/web/wjdt_674879/${categories[category]}`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
let items = $('ul.list1 li a')
|
||||
.slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 35)
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
|
||||
return {
|
||||
title: item.text(),
|
||||
link: item.attr('href').replace(/^\./, currentUrl),
|
||||
};
|
||||
});
|
||||
|
||||
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);
|
||||
|
||||
item.description = content('#News_Body_Txt_A').html();
|
||||
item.pubDate = timezone(parseDate(content('.time span').last().text()), +8);
|
||||
item.category = content('meta[name="Keywords"]').attr('content')?.split(';') ?? [];
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -433,4 +433,15 @@ module.exports = {
|
||||
},
|
||||
],
|
||||
},
|
||||
'mfa.gov.cn': {
|
||||
_name: '中华人民共和国外交部',
|
||||
www: [
|
||||
{
|
||||
title: '外交动态',
|
||||
docs: 'https://docs.rsshub.app/government.html#zhong-hua-ren-min-gong-he-guo-wai-jiao-bu-wai-jiao-dong-tai',
|
||||
source: ['/web/wjdt_674879/:category'],
|
||||
target: (params) => `/gov/mfa/wjdt/${params.category.split('_')[0]}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -4,10 +4,12 @@ module.exports = function (router) {
|
||||
router.get('/shenzhen/zzb/:caty/:page?', require('./shenzhen/zzb/index'));
|
||||
router.get('/shanghai/rsj/ksxm', require('./shanghai/rsj/ksxm'));
|
||||
router.get('/shanghai/wsjkw/yqtb', require('./shanghai/wsjkw/yqtb'));
|
||||
router.get('/fmprc/:category?', require('./mfa/wjdt'));
|
||||
router.get('/guangdong/tqyb/tfxtq', require('./guangdong/tqyb/tfxtq'));
|
||||
router.get('/guangdong/tqyb/sncsyjxh', require('./guangdong/tqyb/sncsyjxh'));
|
||||
router.get('/huizhou/zwgk/:category?', require('./huizhou/zwgk/index'));
|
||||
router.get('/sichuan/deyang/govpulicinfo/:countyName/:institutionName?', require('./sichuan/deyang/govpulicinfo'));
|
||||
router.get('/mfa/wjdt/:category?', require('./mfa/wjdt'));
|
||||
router.get('/miit/wjfb/:ministry', require('./miit/wjfb'));
|
||||
router.get('/miit/yjzj', require('./miit/yjzj'));
|
||||
router.get('/miit/zcwj', require('./miit/zcwj'));
|
||||
|
||||
Reference in New Issue
Block a user