feat(route): add new route for moj of gov.cn (#14122)
* feat(route): add new route for moj of gov.cn * fix: typo in path Co-authored-by: Tony <TonyRL@users.noreply.github.com> ---------
This commit is contained in:
parent
4cde3afc68
commit
5f9844bb91
|
|
@ -40,6 +40,7 @@ module.exports = {
|
|||
'/mof/bond/:category?': ['la3rence'],
|
||||
'/mofcom/article/:suffix+': ['LogicJake'],
|
||||
'/moj/aac/news/:type?': ['TonyRL'],
|
||||
'/moj/lfyjzj': ['la3rence'],
|
||||
'/mot/:category?': ['nczitzk'],
|
||||
'/ndrc/fggz/:category?': ['nczitzk'],
|
||||
'/ndrc/xwdt/:category?': ['nczitzk'],
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const DOMAIN = 'www.moj.gov.cn';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = `https://${DOMAIN}`;
|
||||
const currentUrl = `${rootUrl}/lfyjzj/lflfyjzj/index.html`;
|
||||
const { data: response } = await got(currentUrl);
|
||||
const $ = cheerio.load(response);
|
||||
const siteName = $('title:first').text();
|
||||
const theme = $('div.list_title').text();
|
||||
const description = `${siteName} - ${theme}`;
|
||||
const icon = new URL('/images/sfbgw_favicon.ico', rootUrl).href;
|
||||
const indexes = $('ul.newsMsgList_zzy li')
|
||||
.toArray()
|
||||
.map((li) => {
|
||||
const a = $(li).find('a');
|
||||
const pubDate = $(li).find('div.rightData').text();
|
||||
const href = a.prop('href');
|
||||
const link = href.startsWith('http') ? href : new URL(href, currentUrl).href;
|
||||
return {
|
||||
title: a.text(),
|
||||
link,
|
||||
pubDate: timezone(parseDate(pubDate), +8),
|
||||
};
|
||||
});
|
||||
|
||||
const items = await Promise.all(
|
||||
indexes.map((item) =>
|
||||
ctx.cache.tryGet(`gov:mof:${item.link}`, async () => {
|
||||
const { data: detailResponse } = await got(item.link);
|
||||
const content = cheerio.load(detailResponse);
|
||||
item.description = content('div.TRS_Editor').html();
|
||||
item.author = content('div.sT_left span:first').text().split(':')[1];
|
||||
const pubDate = content('div.sT_left span:last').text().split(':')[1];
|
||||
item.pubDate = pubDate ? timezone(parseDate(pubDate), +8) : item.pubDate;
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
item: items,
|
||||
title: theme,
|
||||
link: currentUrl,
|
||||
description,
|
||||
author: siteName,
|
||||
icon,
|
||||
};
|
||||
};
|
||||
|
|
@ -1273,6 +1273,17 @@ module.exports = {
|
|||
},
|
||||
],
|
||||
},
|
||||
'moj.gov.cn': {
|
||||
_name: '中华人民共和国司法部',
|
||||
www: [
|
||||
{
|
||||
title: '立法意见征集',
|
||||
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-si-fa-bu',
|
||||
source: ['/lfyjzj/lflfyjzj/*', '/pub/sfbgw/lfyjzj/lflfyjzj/*'],
|
||||
target: '/gov/moj/lfyjzj',
|
||||
},
|
||||
],
|
||||
},
|
||||
'moj.gov.tw': {
|
||||
_name: '台灣法務部廉政署',
|
||||
'www.aac': [
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ module.exports = function (router) {
|
|||
router.get('/mof/bond/:category?', require('./mof/bond'));
|
||||
router.get('/mofcom/article/:suffix+', require('./mofcom/article'));
|
||||
router.get('/moj/aac/news/:type?', require('./moj/aac/news'));
|
||||
router.get('/moj/lfyjzj', require('./moj/lfyjzj'));
|
||||
router.get('/ndrc/fggz/:category*', require('./ndrc/fggz'));
|
||||
router.get('/ndrc/xwdt/:category*', require('./ndrc/xwdt'));
|
||||
router.get('/nea/sjzz/ghs', require('./nea/ghs'));
|
||||
|
|
|
|||
|
|
@ -2032,6 +2032,12 @@
|
|||
| :------: | :------: | :------: | :------: | :------: | :------: |
|
||||
| szyw | hjywnews | dfnews | xwfb | spxw | gsgg |
|
||||
|
||||
## 中华人民共和国司法部 {#zhong-hua-ren-min-gong-he-guo-si-fa-bu}
|
||||
|
||||
### 立法意见征集 {#zhong-hua-ren-min-gong-he-guo-si-fa-bu-li-fa-yi-jian-zheng-ji}
|
||||
|
||||
<Route author="la3rence" example="/gov/moj/lfyjzj" path="/gov/moj/lfyjzj" radar="1" />
|
||||
|
||||
## 中华人民共和国退役军人事务部 {#zhong-hua-ren-min-gong-he-guo-tui-yi-jun-ren-shi-wu-bu}
|
||||
|
||||
### 中华人民共和国退役军人事务部 {#zhong-hua-ren-min-gong-he-guo-tui-yi-jun-ren-shi-wu-bu-zhong-hua-ren-min-gong-he-guo-tui-yi-jun-ren-shi-wu-bu}
|
||||
|
|
|
|||
Loading…
Reference in New Issue