diff --git a/lib/v2/gov/maintainer.js b/lib/v2/gov/maintainer.js index 03abde8e6..b5bf37a17 100644 --- a/lib/v2/gov/maintainer.js +++ b/lib/v2/gov/maintainer.js @@ -49,6 +49,8 @@ module.exports = { '/pbc/tradeAnnouncement': ['nczitzk'], '/pbc/zcyj': ['Fatpandac'], '/samr/xgzlyhd/:category?/:department?': ['nczitzk'], + '/safe/bussiness/:site?': ['nczitzk'], + '/safe/complaint/:site?': ['nczitzk'], '/sasac/:path+': ['TonyRL'], '/stats/:path+': ['bigfei', 'nczitzk'], '/zhengce/govall/:advance?': ['ciaranchen'], diff --git a/lib/v2/gov/radar.js b/lib/v2/gov/radar.js index f1d7eb875..0417214b6 100644 --- a/lib/v2/gov/radar.js +++ b/lib/v2/gov/radar.js @@ -1185,6 +1185,31 @@ module.exports = { }, ], }, + 'safe.gov.cn': { + _name: '国家外汇管理局', + '.': [ + { + title: '业务咨询', + docs: 'https://docs.rsshub.app/routes/government#guo-jia-wai-hui-guan-li-ju-ye-wu-zi-xun', + source: ['/:site/ywzx/index.html'], + target: (params) => { + const site = params.site; + + return `/gov/safe/business/${site}`; + }, + }, + { + title: '投诉建议', + docs: 'https://docs.rsshub.app/routes/government#guo-jia-wai-hui-guan-li-ju-tou-su-jian-yi', + source: ['/:site/tsjy/index.html'], + target: (params) => { + const site = params.site; + + return `/gov/safe/complaint/${site}`; + }, + }, + ], + }, 'sasac.gov.cn': { _name: '国务院国有资产监督管理委员会', '.': [ diff --git a/lib/v2/gov/router.js b/lib/v2/gov/router.js index 038443f0a..2f93ef4ed 100644 --- a/lib/v2/gov/router.js +++ b/lib/v2/gov/router.js @@ -41,6 +41,8 @@ module.exports = function (router) { router.get('/pbc/gzlw', require('./pbc/gzlw')); router.get('/pbc/tradeAnnouncement', require('./pbc/tradeAnnouncement')); router.get('/pbc/zcyj', require('./pbc/zcyj')); + router.get('/safe/business/:site?', require('./safe/business')); + router.get('/safe/complaint/:site?', require('./safe/complaint')); router.get('/samr/xgzlyhd/:category?/:department?', require('./samr/xgzlyhd')); router.get('/sasac/:path+', require('./sasac/generic')); router.get(/stats(\/[\w/-]+)?/, require('./stats')); diff --git a/lib/v2/gov/safe/business.js b/lib/v2/gov/safe/business.js new file mode 100644 index 000000000..c9dc1c3b0 --- /dev/null +++ b/lib/v2/gov/safe/business.js @@ -0,0 +1,8 @@ +const { processZxfkItems } = require('./util'); + +module.exports = async (ctx) => { + const { site = 'beijing' } = ctx.params; + const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 3; + + ctx.state.data = await processZxfkItems(site, 'ywzx', limit); +}; diff --git a/lib/v2/gov/safe/complaint.js b/lib/v2/gov/safe/complaint.js new file mode 100644 index 000000000..d3f883be5 --- /dev/null +++ b/lib/v2/gov/safe/complaint.js @@ -0,0 +1,8 @@ +const { processZxfkItems } = require('./util'); + +module.exports = async (ctx) => { + const { site = 'beijing' } = ctx.params; + const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 5; + + ctx.state.data = await processZxfkItems(site, 'tsjy', limit); +}; diff --git a/lib/v2/gov/safe/templates/message.art b/lib/v2/gov/safe/templates/message.art new file mode 100644 index 000000000..bb909b2f6 --- /dev/null +++ b/lib/v2/gov/safe/templates/message.art @@ -0,0 +1,25 @@ + + + + + + + + {{ if message }} + {{ set object = message }} + + + + + + {{ /if }} + {{ if reply }} + {{ set object = reply }} + + + + + + {{ /if }} + +
留言人留言内容留言时间
{{ object.author }}{{ object.content }}{{ object.date }}
{{ object.author }}{{ object.content }}{{ object.date }}
\ No newline at end of file diff --git a/lib/v2/gov/safe/util.js b/lib/v2/gov/safe/util.js new file mode 100644 index 000000000..8fb315f13 --- /dev/null +++ b/lib/v2/gov/safe/util.js @@ -0,0 +1,87 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const { art } = require('@/utils/render'); +const path = require('path'); + +const rootUrl = 'https://www.safe.gov.cn'; + +const zxfkCategoryApis = { + // 业务咨询 https://www.safe.gov.cn//ywzx/index.html + ywzx: 'www/busines/businessQuery?siteid=', + + // 投诉建议 https://www.safe.gov.cn//tsjy/index.html + tsjy: 'www/complaint/complaintQuery?siteid=', +}; + +const processZxfkItems = async (site = 'beijing', category = 'ywzx', limit = '3') => { + const apiUrl = new URL(`${zxfkCategoryApis[category]}${site}`, rootUrl).href; + const currentUrl = new URL(`${site}/${category}/index.html`, rootUrl).href; + + const { data: response } = await got(apiUrl); + + const $ = cheerio.load(response); + + const items = $('#complaint') + .slice(0, limit) + .toArray() + .map((item) => { + item = $(item); + + const spans = item.find('span[objid]'); + + const message = { + author: spans.first().text().replace(/:$/, ''), + content: spans.eq(1).text(), + date: spans.eq(2).text(), + }; + + const reply = { + author: spans.eq(3).text().replace(/:$/, ''), + content: spans.eq(4).text(), + date: spans.eq(5).text(), + }; + + return { + title: `${message.author}: ${message.content}`, + link: new URL(item.find('.title').prop('href'), rootUrl).href, + description: art(path.join(__dirname, 'templates/message.art'), { + message, + reply, + }), + author: `${message.author}/${reply.author}`, + guid: item.find('.id').text(), + pubDate: parseDate(message.date), + updated: parseDate(reply.date), + }; + }); + + const { data: currentResponse } = await got(currentUrl); + + const content = cheerio.load(currentResponse); + + const author = content('meta[name="ColumnName"]').prop('content'); + const subtitle = content('meta[name="ColumnType"]').prop('content'); + + const imagePath = 'safe/templateresource/372b1dfdab204181b9b4f943a8e926a6'; + const image = new URL(`${imagePath}/logo_06.png`, rootUrl).href; + const icon = new URL(`${imagePath}/safe.ico`, rootUrl).href; + + return { + item: items, + title: `${author} - ${subtitle}`, + link: currentUrl, + description: content('meta[name="ColumnDescription"]').prop('content'), + language: 'zh', + image, + icon, + logo: icon, + subtitle, + author, + allowEmpty: true, + }; +}; + +module.exports = { + processZxfkItems, +}; diff --git a/website/docs/routes/government.mdx b/website/docs/routes/government.mdx index 3ba1b5bf1..e9d2a400d 100644 --- a/website/docs/routes/government.mdx +++ b/website/docs/routes/government.mdx @@ -618,6 +618,57 @@ Language +## 国家外汇管理局 {#guo-jia-wai-hui-guan-li-ju} + +
+ *业务咨询* 和 *投诉建议* 可用的站点参数 + + | 上海市 | 北京市 | 天津市 | 河北省 | + | -------- | ------- | ------- | ----- | + | shanghai | beijing | tianjin | hebei | + + | 山西省 | 内蒙古自治区 | 辽宁省 | 吉林省 | + | ------ | --------- | -------- | ----- | + | shanxi | neimenggu | liaoning | jilin | + + | 黑龙江省 | 江苏省 | 浙江省 | 安徽省 | + | ------------ | ------- | -------- | ----- | + | heilongjiang | jiangsu | zhejiang | anhui | + + | 福建省 | 江西省 | 山东省 | 河南省 | + | ------ | ------- | -------- | ----- | + | fujian | jiangxi | shandong | henan | + + | 湖北省 | 湖南省 | 广东省 | 广西壮族自治区 | + | ----- | ----- | --------- | ------- | + | hubei | hunan | guangdong | guangxi | + + | 海南省 | 重庆市 | 四川省 | 贵州省 | + | ------ | --------- | ------- | ------- | + | hainan | chongqing | sichuan | guizhou | + + | 云南省 | 西藏自治区 | 陕西省 | 甘肃省 | + | ------ | ------ | ------- | ----- | + | yunnan | xizang | shaanxi | gansu | + + | 青海省 | 宁夏回族自治区 | 新疆维吾尔自治区 | 大连市 | + | ------- | ------- | -------- | ------ | + | qinghai | ningxia | xinjiang | dalian | + + | 宁波市 | 厦门市 | 青岛市 | 深圳市 | + | ------ | ------ | ------- | -------- | + | ningbo | xiamen | qingdao | shenzhen | + +
+ +### 业务咨询 {#guo-jia-wai-hui-guan-li-ju-ye-wu-zi-xun} + + + +### 投诉建议 {#guo-jia-wai-hui-guan-li-ju-tou-su-jian-yi} + + + ## 国家新闻出版广电总局(弃用) {#guo-jia-xin-wen-chu-ban-guang-dian-zong-ju-qi-yong} ### 游戏审批结果 {#guo-jia-xin-wen-chu-ban-guang-dian-zong-ju-qi-yong-you-xi-shen-pi-jie-guo}