feat(route): moe (#11926)
This commit is contained in:
parent
485628eae8
commit
4ca2c8cdc4
|
|
@ -1474,6 +1474,10 @@ pageClass: routes
|
|||
|
||||
</Route>
|
||||
|
||||
### 司局通知
|
||||
|
||||
<Route author="TonyRL" example="/gov/moe/s78/A13" path="/gov/moe/s78/:column" :paramsDesc="['司局 ID,可在 URL 找到']" radar="1"/>
|
||||
|
||||
## 中华人民共和国农业农村部
|
||||
|
||||
### 新闻
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ module.exports = {
|
|||
'/miit/wjgs': ['Yoge-Code'],
|
||||
'/miit/zcjd': ['Yoge-Code'],
|
||||
'/moe/:type': ['Crawler995'],
|
||||
'/moe/s78/:column': ['TonyRL'],
|
||||
'/mofcom/article/:suffix+': ['LogicJake'],
|
||||
'/moj/aac/news/:type?': ['TonyRL'],
|
||||
'/nifdc/:path+': ['nczitzk'],
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@ module.exports = async (ctx) => {
|
|||
let id = '';
|
||||
let name = '';
|
||||
|
||||
for (let i = 0; i < typesIdMap.length; i++) {
|
||||
if (typesIdMap[i].type === type) {
|
||||
id = typesIdMap[i].id;
|
||||
name = typesIdMap[i].name;
|
||||
for (const item of typesIdMap) {
|
||||
if (item.type === type) {
|
||||
id = item.id;
|
||||
name = item.name;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const baseUrl = 'https://www.moe.gov.cn';
|
||||
const { column } = ctx.params;
|
||||
const link = `${baseUrl}/s78/${column}/tongzhi/`;
|
||||
|
||||
const { data: response } = await got(link);
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
const list = $('#list li')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.find('a').attr('title'),
|
||||
link: new URL(item.find('a').attr('href'), link).href,
|
||||
pubDate: timezone(parseDate(item.find('span').text(), 'YYYY-MM-DD'), +8),
|
||||
};
|
||||
});
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data: response } = await got(item.link);
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
$('#moe-detail-page-set, #moeCode, .moe-detail-shuxing, h1').remove();
|
||||
item.description = $('.moe-detail-box').html();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${$('meta[name="ColumnType"]').attr('content')} - ${$('head title').text()}`,
|
||||
link,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -681,6 +681,12 @@ module.exports = {
|
|||
source: ['/'],
|
||||
target: '/gov/moe/newest_file',
|
||||
},
|
||||
{
|
||||
title: '司局通知',
|
||||
docs: 'https://docs.rsshub.app/government.html#zhong-hua-ren-min-gong-he-guo-jiao-yu-bu',
|
||||
source: ['/s78/:column/tongzhi', '/s78/:column'],
|
||||
target: '/gov/moe/s78/:column',
|
||||
},
|
||||
],
|
||||
},
|
||||
'mofcom.gov.cn': {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ module.exports = function (router) {
|
|||
router.get('/miit/wjgs', require('./miit/wjgs'));
|
||||
router.get('/miit/zcjd', require('./miit/zcjd'));
|
||||
router.get('/moe/:type', require('./moe/moe'));
|
||||
router.get('/moe/s78/:column', require('./moe/s78'));
|
||||
router.get('/mofcom/article/:suffix+', require('./mofcom/article'));
|
||||
router.get('/moj/aac/news/:type?', require('./moj/aac/news'));
|
||||
router.get(/nifdc\/([\w/-]+)?/, require('./nifdc'));
|
||||
|
|
|
|||
Loading…
Reference in New Issue