diff --git a/lib/v2/gov/maintainer.js b/lib/v2/gov/maintainer.js index cfbb2c6a8d0a63..c7c01ac4e714eb 100644 --- a/lib/v2/gov/maintainer.js +++ b/lib/v2/gov/maintainer.js @@ -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'], diff --git a/lib/v2/gov/moj/lfyjzj.js b/lib/v2/gov/moj/lfyjzj.js new file mode 100644 index 00000000000000..2e826fbd9c0eae --- /dev/null +++ b/lib/v2/gov/moj/lfyjzj.js @@ -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, + }; +}; diff --git a/lib/v2/gov/radar.js b/lib/v2/gov/radar.js index 8b805f8a3b03e5..35da7bc7942777 100644 --- a/lib/v2/gov/radar.js +++ b/lib/v2/gov/radar.js @@ -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': [ diff --git a/lib/v2/gov/router.js b/lib/v2/gov/router.js index 65720984336cb1..1164beb421f0ee 100644 --- a/lib/v2/gov/router.js +++ b/lib/v2/gov/router.js @@ -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')); diff --git a/website/docs/routes/government.mdx b/website/docs/routes/government.mdx index f1458051181516..9cd45d80a1b452 100644 --- a/website/docs/routes/government.mdx +++ b/website/docs/routes/government.mdx @@ -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} + + + ## 中华人民共和国退役军人事务部 {#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}