mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat(route): add 工业和信息化部 (#9221)
* feat(route): add 工业和信息化部 * fix(route): change route path, docs and refactor to V2
This commit is contained in:
@@ -498,6 +498,14 @@ pageClass: routes
|
||||
|
||||
<Route author="Yoge-Code" example="/gov/miit/zcjd" path="/gov/miit/zcjd"/>
|
||||
|
||||
### 文件发布
|
||||
|
||||
<Route author="Fatpandac" example="/gov/miit/wjfb/ghs" path="/gov/miit/wjfb/:ministry" :paramsDesc="['部门缩写,可以在对应 URL 中获取']"/>
|
||||
|
||||
### 意见征集
|
||||
|
||||
<Route author="Fatpandac" example="/gov/miit/yjzj" path="/gov/miit/yjzj"/>
|
||||
|
||||
### 文件公示
|
||||
|
||||
<Route author="Yoge-Code" example="/gov/miit/wjgs" path="/gov/miit/wjgs"/>
|
||||
|
||||
@@ -2294,11 +2294,6 @@ router.get('/noi/winners-list', lazyloadRouteHandler('./routes/noi/winners-list'
|
||||
router.get('/noi/province-news', lazyloadRouteHandler('./routes/noi/province-news'));
|
||||
router.get('/noi/rg-news', lazyloadRouteHandler('./routes/noi/rg-news'));
|
||||
|
||||
// 中国工业化和信息部
|
||||
router.get('/gov/miit/zcwj', lazyloadRouteHandler('./routes/gov/miit/zcwj'));
|
||||
router.get('/gov/miit/wjgs', lazyloadRouteHandler('./routes/gov/miit/wjgs'));
|
||||
router.get('/gov/miit/zcjd', lazyloadRouteHandler('./routes/gov/miit/zcjd'));
|
||||
|
||||
// 中国国家认证认可监管管理员会
|
||||
router.get('/gov/cnca/jgdt', lazyloadRouteHandler('./routes/gov/cnca/jgdt'));
|
||||
router.get('/gov/cnca/hydt', lazyloadRouteHandler('./routes/gov/cnca/hydt'));
|
||||
|
||||
@@ -7,4 +7,9 @@ module.exports = {
|
||||
'/guangdong/tqyb/sncsyjxh': ['Fatpandac'],
|
||||
'/huizhou/zwgk/:category?': ['Fatpandac'],
|
||||
'/sichuan/deyang/govpulicinfo/:countyName/:institutionName?': ['zytomorrow'],
|
||||
'/miit/wjfb/:ministry': ['Fatpandac'],
|
||||
'/miit/yjzj': ['Fatpandac'],
|
||||
'/miit/zcwj': ['Yoge-Code'],
|
||||
'/miit/wjgs': ['Yoge-Code'],
|
||||
'/miit/zcjd': ['Yoge-Code'],
|
||||
};
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const rootUrl = 'https://www.miit.gov.cn';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const ministry = ctx.params.ministry;
|
||||
const url = `${rootUrl}/jgsj/${ministry}/wjfb/index.html`;
|
||||
|
||||
const cookieResponse = await got(url);
|
||||
const cookie = cookieResponse.headers['set-cookie'][0].split(';')[0];
|
||||
const indexContent = cheerio.load(cookieResponse.data);
|
||||
const title = indexContent('div.dqwz > a:nth-child(4)').text();
|
||||
const dataRequestUrl = indexContent('div.lmy_main_rb > script:nth-child(2)')
|
||||
.map((_, item) => ({
|
||||
url: `${rootUrl}${indexContent(item).attr('url')}`,
|
||||
queryData: JSON.parse(indexContent(item).attr('querydata').replace(/"/g, '|').replace(/'/g, '"').replace(/\|/g, '"')),
|
||||
}))
|
||||
.get()[0];
|
||||
|
||||
const dataUrl = `${dataRequestUrl.url}?${Object.keys(dataRequestUrl.queryData)
|
||||
.map((key) => `${key}=${dataRequestUrl.queryData[key]}`)
|
||||
.join('&')}`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: dataUrl,
|
||||
headers: {
|
||||
Cookie: cookie,
|
||||
},
|
||||
});
|
||||
const $ = cheerio.load(response.data.data.html);
|
||||
const list = $('ul > li')
|
||||
.map((_, item) => ({
|
||||
title: $(item).find('a').text(),
|
||||
link: new URL($(item).find('a').attr('href'), rootUrl).href,
|
||||
pubDate: parseDate($(item).find('span').text(), 'YYYY-MM-DD'),
|
||||
}))
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got(item.link);
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.description = content('#con_con')
|
||||
.html()
|
||||
.replace(/(<iframe.*?src=")(.*?)(".*?>)/g, '$1' + rootUrl + '$2' + '$3');
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `工业和信息化部 - ${title} 文件发布`,
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,59 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const rootUrl = 'https://www.miit.gov.cn';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const url = `${rootUrl}/gzcy/yjzj/index.html`;
|
||||
|
||||
const cookieResponse = await got(url);
|
||||
const cookie = cookieResponse.headers['set-cookie'][0].split(';')[0];
|
||||
const indexContent = cheerio.load(cookieResponse.data);
|
||||
const dataRequestUrl = indexContent('div.clist_con > script:nth-child(2)')
|
||||
.map((_, item) => ({
|
||||
url: `${rootUrl}${indexContent(item).attr('url')}`,
|
||||
queryData: JSON.parse(indexContent(item).attr('querydata').replace(/"/g, '|').replace(/'/g, '"').replace(/\|/g, '"')),
|
||||
}))
|
||||
.get()[0];
|
||||
|
||||
const dataUrl = `${dataRequestUrl.url}?${Object.keys(dataRequestUrl.queryData)
|
||||
.map((key) => `${key}=${dataRequestUrl.queryData[key]}`)
|
||||
.join('&')}`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: dataUrl,
|
||||
headers: {
|
||||
Cookie: cookie,
|
||||
},
|
||||
});
|
||||
const $ = cheerio.load(response.data.data.html);
|
||||
const list = $('ul > li')
|
||||
.map((_, item) => ({
|
||||
title: $(item).find('a').text(),
|
||||
link: new URL($(item).find('a').attr('href'), rootUrl).href,
|
||||
pubDate: parseDate($(item).find('span').text(), 'YYYY-MM-DD'),
|
||||
}))
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got(item.link);
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.description = content('#con_con')
|
||||
.html()
|
||||
.replace(/(<iframe.*?src=")(.*?)(".*?>)/g, '$1' + rootUrl + '$2' + '$3');
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `工业和信息化部 - 意见征集`,
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -376,4 +376,21 @@ module.exports = {
|
||||
},
|
||||
],
|
||||
},
|
||||
'miit.gov.cn': {
|
||||
_name: '工业和信息化部',
|
||||
'.': [
|
||||
{
|
||||
title: '部门 文件发布',
|
||||
docs: 'https://docs.rsshub.app/government.html#zhong-guo-gong-ye-he-xin-xi-hua-bu',
|
||||
source: ['/jgsj/:ministry/wjfb/index.html'],
|
||||
target: '/miit/wjfb/:ministry',
|
||||
},
|
||||
{
|
||||
title: '征集意见',
|
||||
docs: 'https://docs.rsshub.app/government.html#zhong-guo-gong-ye-he-xin-xi-hua-bu',
|
||||
source: ['/gzcy/yjzj/index.html'],
|
||||
target: '/miit/yjzj',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -8,4 +8,9 @@ module.exports = function (router) {
|
||||
router.get('/guangdong/tqyb/sncsyjxh', require('./guangdong/tqyb/sncsyjxh'));
|
||||
router.get('/huizhou/zwgk/:category?', require('./huizhou/zwgk/index'));
|
||||
router.get('/sichuan/deyang/govpulicinfo/:countyName/:institutionName?', require('./sichuan/deyang/govpulicinfo'));
|
||||
router.get('/miit/wjfb/:ministry', require('./miit/wjfb'));
|
||||
router.get('/miit/yjzj', require('./miit/yjzj'));
|
||||
router.get('/miit/zcwj', require('./miit/zcwj'));
|
||||
router.get('/miit/wjgs', require('./miit/wjgs'));
|
||||
router.get('/miit/zcjd', require('./miit/zcjd'));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user