Skip to content

Commit

Permalink
Merge pull request #1305 from DIYgod/master
Browse files Browse the repository at this point in the history
[pull] master from diygod:master
  • Loading branch information
pull[bot] authored Dec 27, 2023
2 parents 3646ffc + 5f9844b commit 14f1984
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/v2/gov/maintainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
53 changes: 53 additions & 0 deletions lib/v2/gov/moj/lfyjzj.js
Original file line number Diff line number Diff line change
@@ -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,
};
};
11 changes: 11 additions & 0 deletions lib/v2/gov/radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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': [
Expand Down
1 change: 1 addition & 0 deletions lib/v2/gov/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
6 changes: 6 additions & 0 deletions website/docs/routes/government.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 14f1984

Please sign in to comment.