mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat: add 中国政府网图解 & 漫画 (#5550)
This commit is contained in:
@@ -155,6 +155,18 @@ pageClass: routes
|
||||
|
||||
</Route>
|
||||
|
||||
### 图解
|
||||
|
||||
<Route author="nczitzk" example="/gov/xinwen/tujie/zhengce" path="/gov/xinwen/tujie/:caty" :paramsDesc="['图解分类,见下表']">
|
||||
|
||||
| 总理活动图解 | 每周一画 | 其他漫画 | 图解政策 | 其他图解 |
|
||||
| ------------ | -------- | -------- | -------- | -------- |
|
||||
| zlhd | mzyh | qtmh | zhengce | qttj |
|
||||
|
||||
全部分类参见 [图解图表](http://www.gov.cn/xinwen/tujie/index.htm)
|
||||
|
||||
</Route>
|
||||
|
||||
### 最新政策
|
||||
|
||||
<Route author="SettingDust" example="/gov/zhengce/zuixin" path="/gov/zhengce/zuixin"/>
|
||||
|
||||
@@ -1211,6 +1211,7 @@ router.get('/gov/city/:name/:category', require('./routes/gov/city'));
|
||||
router.get('/gov/statecouncil/briefing', require('./routes/gov/statecouncil/briefing'));
|
||||
router.get('/gov/news/:uid', require('./routes/gov/news'));
|
||||
router.get('/gov/shuju/:caty/:item', require('./routes/gov/shuju'));
|
||||
router.get('/gov/xinwen/tujie/:caty', require('./routes/gov/xinwen/tujie'));
|
||||
|
||||
// 苏州
|
||||
router.get('/gov/suzhou/news/:uid', require('./routes/gov/suzhou/news'));
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
const config = {
|
||||
zlhd: {
|
||||
link: '/tujie/zlhd.htm',
|
||||
title: '总理活动图解',
|
||||
},
|
||||
mzyh: {
|
||||
link: '/manhua/mzyh.htm',
|
||||
title: '每周一画',
|
||||
},
|
||||
qtmh: {
|
||||
link: '/manhua/qita.htm',
|
||||
title: '其他漫画',
|
||||
},
|
||||
zhengce: {
|
||||
link: '/tujie/zhengce.htm',
|
||||
title: '图解政策',
|
||||
},
|
||||
qttj: {
|
||||
link: '/tujie/qita.htm',
|
||||
title: '其他图解',
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const cfg = config[ctx.params.caty];
|
||||
if (!cfg) {
|
||||
throw Error('Bad category. See <a href="https://docs.rsshub.app/government.html#zhong-guo-zheng-fu-tu-jie">docs</a>');
|
||||
}
|
||||
|
||||
const rootUrl = 'http://www.gov.cn/xinwen';
|
||||
const currentUrl = rootUrl + cfg.link;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('div.Video_pane div.tplgd')
|
||||
.slice(0, 15)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
const a = item.find('a').eq(1);
|
||||
return {
|
||||
title: a.text(),
|
||||
link: `http://www.gov.cn${a.attr('href')}`,
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.description = content('div.pages_content').html();
|
||||
item.pubDate = new Date(content('div.pages-date').text().split('来源:')[0] + ' GMT+8').toUTCString();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${cfg.title} - 中国政府网`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user