diff --git a/assets/radar-rules.js b/assets/radar-rules.js index 622e8471128..b78f8019c1d 100644 --- a/assets/radar-rules.js +++ b/assets/radar-rules.js @@ -1237,4 +1237,14 @@ }, ], }, + 'beijing.gov.cn': { + wjw: [ + { + title: '北京卫生健康委员会', + docs: 'https://docs.rsshub.app/government.html#zhong-yang-ji-wei-guo-jia-jian-wei', + source: '/xwzx_20031/:caty', + target: '/gov/beijing/mhc/:caty', + }, + ], + }, }); diff --git a/docs/government.md b/docs/government.md index 7661bbe6fa5..214b808795a 100644 --- a/docs/government.md +++ b/docs/government.md @@ -4,6 +4,18 @@ pageClass: routes # 政务消息 +## 北京市卫生健康委员会 + +### 新闻中心 + + + +| 委内新闻 | 基层动态 | 媒体聚焦 | 热点新闻 | +| :------: | :------: | :------: | :------: | +| wnxw | jcdt | mtjj | rdxws | + + + ## 国家新闻出版广电总局 ### 游戏审批结果 diff --git a/lib/router.js b/lib/router.js index 154e263f6dd..3d1b9d25658 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1125,6 +1125,9 @@ router.get('/gov/fmprc/fyrbt', require('./routes/gov/fmprc/fyrbt')); // 国家新闻出版广电总局 router.get('/gov/sapprft/approval/:channel/:detail?', require('./routes/gov/sapprft/7026')); +// 北京卫生健康委员会 +router.get('/gov/beijing/mhc/:caty', require('./routes/gov/beijing/mhc')); + // 小黑盒 router.get('/xiaoheihe/user/:id', require('./routes/xiaoheihe/user')); router.get('/xiaoheihe/news', require('./routes/xiaoheihe/news')); diff --git a/lib/routes/gov/beijing/mhc.js b/lib/routes/gov/beijing/mhc.js new file mode 100644 index 00000000000..36db3e197e2 --- /dev/null +++ b/lib/routes/gov/beijing/mhc.js @@ -0,0 +1,69 @@ +const url = require('url'); +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +const root_url = 'http://wjw.beijing.gov.cn/'; + +const config = { + wnxw: { + link: '/xwzx_20031/wnxw/', + title: '委内新闻', + }, + jcdt: { + link: '/xwzx_20031/jcdt/', + title: '基层动态', + }, + mtjj: { + link: '/xwzx_20031/mtjj/', + title: '媒体聚焦', + }, + rdxws: { + link: '/xwzx_20031/rdxws/', + title: '热点新闻', + }, +}; + +module.exports = async (ctx) => { + const cfg = config[ctx.params.caty]; + if (!cfg) { + throw Error('Bad category. See docs'); + } + + const current_url = url.resolve(root_url, cfg.link); + const response = await got({ + method: 'get', + url: current_url, + }); + const $ = cheerio.load(response.data); + const list = $('div.weinei_left_con div.weinei_left_con_line') + .slice(0, 10) + .map((_, item) => { + item = $(item); + const a = item.find('a[title]'); + return { + title: a.text(), + link: url.resolve(current_url, a.attr('href')), + pubDate: new Date(item.find('div.weinei_left_con_line_date').text() + ' GMT+8').toUTCString(), + }; + }) + .get(); + + const items = await Promise.all( + list.map( + async (item) => + await ctx.cache.tryGet(item.link, async () => { + const res = await got({ method: 'get', url: item.link }); + const content = cheerio.load(res.data); + + item.description = content('div.weinei_left').html(); + return item; + }) + ) + ); + + ctx.state.data = { + title: '北京卫健委 - ' + cfg.title, + link: root_url, + item: items, + }; +};