feat(route): add gov/sichuan/deyang/mztoday (#12213)

* feat(route): add gov/sichuan/deyang/mztoday

* feat(route): add gov/sichuan/deyang/mztoday

* feat(route): add gov/sichuan/deyang/mztoday

* feat(route): add gov/sichuan/deyang/mztoday

* Update lib/v2/gov/sichuan/deyang/mztoday.js

* fix: update maintainer and radar

---------

Co-authored-by: zytomorrow <z794672847@gamil.com>
This commit is contained in:
zytomorrow 2023-04-05 03:26:36 +08:00 committed by GitHub
parent a1be32deeb
commit 8c66b20220
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 161 additions and 0 deletions

View File

@ -156,6 +156,16 @@ pageClass: routes
</Route>
### 今日绵竹
<Route author="zytomorrow" example="/gov/sichuan/deyang/mztoday/zx" path="/gov/sichuan/deyang/mztoday/:infoType?" :paramsDesc="['信息栏目名称。默认最新(zx)']">
| 最新 | 推荐 | 时政 | 教育 | 民生 | 文旅 | 经济 | 文明创建 | 部门 | 镇(街道) | 健康绵竹 | 南轩讲堂 | 视频 | 文明实践 | 领航中国 | 绵竹年画 | 绵竹历史 | 绵竹旅游 | 外媒看绵竹 |
| ---- | ---- | ---- | ---- | ---- | ---- | ---- | -------- | ---- | ---------- | -------- | -------- | ---- | -------- | -------- | -------- | -------- | -------- | ---------- |
| zx | tj | sz | jy | ms | wl | jj | wmcj | bm | zj | jkmz | nxjt | sp | wmsj | lhzg | mznh | mzls | mzly | wmkmz |
</Route>
## 广东省人民政府
### 省教育厅

View File

@ -73,6 +73,7 @@ module.exports = {
'/shenzhen/xxgk/zfxxgj/:caty': ['laoxua'],
'/shenzhen/zzb/:caty/:page?': ['zlasd'],
'/sichuan/deyang/govpublicinfo/:countyName/:infoType?': ['zytomorrow'],
'/sichuan/deyang/mztoday/:infoType?': ['zytomorrow'],
'/taiyuan/rsj/:caty/:page?': ['2PoL'],
'/wuhan/sy/whyw': ['nczitzk'],
'/xinyi/:path+': ['ShuiHuo'],

View File

@ -741,6 +741,17 @@ module.exports = {
},
],
},
'mztoday.gov.cn': {
_name: '德阳市人民政府',
www: [
{
title: '今日绵竹',
docs: 'https://docs.rsshub.app/government.html#de-yang-shi-ren-min-zheng-fu',
source: ['/*'],
target: '/gov/sichuan/deyang/mztoday',
},
],
},
'nifdc.gov.cn': {
_name: '国家药品监督管理局医疗器械标准管理中心',
'.': [

View File

@ -64,6 +64,7 @@ module.exports = function (router) {
router.get('/shenzhen/xxgk/zfxxgj/:caty', require('./shenzhen/xxgk/zfxxgj'));
router.get('/shenzhen/zzb/:caty/:page?', require('./shenzhen/zzb/index'));
router.get('/sichuan/deyang/govpublicinfo/:countyName/:infoType?', require('./sichuan/deyang/govpublicinfo'));
router.get('/sichuan/deyang/mztoday/:infoType?', require('./sichuan/deyang/mztoday'));
router.get('/taiyuan/rsj/:caty/:page?', require('./taiyuan/rsj'));
router.get('/wuhan/sy/whyw', require('./wuhan/whyw'));
router.get(/xinyi(\/[\w/-]+)?/, require('./xinyi/xinyi'));

View File

@ -0,0 +1,132 @@
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 timezone = require('@/utils/timezone');
const rootUrl = 'http://www.mztoday.gov.cn';
const basicInfoDict = {
zx: {
name: '最新',
url: '/news.html?page=1',
},
tj: {
name: '推荐',
url: '/list/42.html?page=1',
},
sz: {
name: '时政',
url: '/list/39.html?page=1',
},
jy: {
name: '教育',
url: '/list/40.html?page=1',
},
ms: {
name: '民生',
url: '/list/41.html?page=1',
},
wl: {
name: '文旅',
url: '/list/41.html?page=1',
},
jj: {
name: '经济',
url: '/list/53.html?page=1',
},
wwcj: {
name: '文明创建',
url: '/list/54.html?page=1',
},
bxsh: {
name: '文明创建',
url: '/list/55.html?page=1',
},
bm: {
name: '部门',
url: '/list/56.html?page=1',
},
zj: {
name: '镇(街道)',
url: '/list/57.html?page=1',
},
jkmz: {
name: '健康绵竹',
url: '/list/59.html?page=1',
},
nxjt: {
name: '南轩讲堂',
url: '/list/70.html?page=1',
},
sp: {
name: '视频',
url: '/vlist.html?page=1',
},
wmsj: {
name: '文明实践',
url: '/list/71.html?page=1',
},
lhzg: {
name: '领航中国',
url: '/list/74.html?page=1',
},
mznh: {
name: '绵竹年画',
url: '/list/36.html?page=1',
},
mzls: {
name: '绵竹历史',
url: '/list/16.html?page=1',
},
mzly: {
name: '绵竹旅游',
url: '/list/37.html?page=1',
},
wwkmz: {
name: '外媒看绵竹',
url: '/list/50.html?page=1',
},
};
const getInfoUrlList = async (url) => {
const response = await got(url);
const $ = cheerio.load(response.data);
const infoList = $('div.sl').toArray().map((item) => ({
title: $('a', item).attr('title'),
url: `${rootUrl}${$('a', item).attr('href')}`,
pubDate: parseDate(timezone($('div > div:nth-child(4)', item).html().trim()), +8),
}));
return infoList;
};
// 获取信息正文内容
const getInfoContent = (ctx, item) =>
ctx.cache.tryGet(item.url, async () => {
const response = await got(item.url);
const $ = cheerio.load(response.data);
return {
title: item.title,
content: $('td:nth-child(2)').html(),
link: item.url,
pubDate: item.pubDate,
};
});
module.exports = async (ctx) => {
const infoType = ctx.params.infoType || 'zx';
const infoBasicUrl = `${rootUrl}${basicInfoDict[infoType].url}`;
const infoUrlList = await getInfoUrlList(infoBasicUrl);
const items = await Promise.all(infoUrlList.map((item) => getInfoContent(ctx, item)));
ctx.state.data = {
title: `今日绵竹-${basicInfoDict[infoType].name}`,
link: `${infoBasicUrl}1`,
item: items.map((item) => ({
title: item.title,
description: art(path.join(__dirname, './templates/mztoday.art'), { item }),
link: item.link,
pubDate: item.pubDate,
})),
};
};

View File

@ -0,0 +1,6 @@
<div>
{{@ item.content}}
</div>