mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
+1
-1
@@ -1247,7 +1247,7 @@ pageClass: routes
|
||||
|
||||
### 政务公开
|
||||
|
||||
<Route author="LogicJake" example="/mofcom/article/b" path="/mofcom/article/:suffix" :paramsDesc="['支持形如`http://www.mofcom.gov.cn/article/*`的网站,传入 article 之后的后缀']" />
|
||||
<Route author="LogicJake" example="/gov/mofcom/article/xwfb" path="/gov/mofcom/article/:suffix+" :paramsDesc="['支持形如 `http://www.mofcom.gov.cn/article/*` 的网站,传入 article 之后的后缀,支持多级']" radar="1" rssbud="1"/>
|
||||
|
||||
## 中华人民共和国生态环境部
|
||||
|
||||
|
||||
+2
-2
@@ -1945,8 +1945,8 @@ router.get('/dhl/:id', lazyloadRouteHandler('./routes/dhl/shipment-tracking'));
|
||||
// Japanpost
|
||||
router.get('/japanpost/track/:reqCode/:locale?', lazyloadRouteHandler('./routes/japanpost/track'));
|
||||
|
||||
// 中华人民共和国商务部
|
||||
router.get('/mofcom/article/:suffix', lazyloadRouteHandler('./routes/mofcom/article'));
|
||||
// 中华人民共和国商务部 migrated to v2
|
||||
// router.get('/mofcom/article/:suffix', lazyloadRouteHandler('./routes/mofcom/article'));
|
||||
|
||||
// 品玩
|
||||
router.get('/pingwest/status', lazyloadRouteHandler('./routes/pingwest/status'));
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
const cheerio = require('cheerio');
|
||||
const got = require('@/utils/got');
|
||||
const { resolve } = require('url');
|
||||
|
||||
const host = 'http://www.mofcom.gov.cn';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const suffix = ctx.params.suffix;
|
||||
const url = resolve('http://www.mofcom.gov.cn/article/', suffix);
|
||||
const res = await got.get(url);
|
||||
const $ = cheerio.load(res.data);
|
||||
const title = $('head > title').text();
|
||||
const list = $('.txtList_01 li').get();
|
||||
|
||||
const out = await Promise.all(
|
||||
list.map(async (item) => {
|
||||
const $ = cheerio.load(item);
|
||||
const title = $('a').attr('title');
|
||||
const sub_url = $('a').attr('href');
|
||||
const itemUrl = resolve(host, sub_url);
|
||||
const cache = await ctx.cache.get(itemUrl);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
|
||||
let responses = await got.get(itemUrl);
|
||||
const redirect = responses.data.match(/window\.location\.href='(.*)'/);
|
||||
if (redirect) {
|
||||
responses = await got.get(redirect[1], {
|
||||
headers: {
|
||||
Referer: itemUrl,
|
||||
'Accept-Encoding': 'gzip, deflate',
|
||||
'Accept-Language': 'zh-CN,zh;q=0.9',
|
||||
Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3',
|
||||
},
|
||||
});
|
||||
}
|
||||
const $d = cheerio.load(responses.data);
|
||||
|
||||
const single = {
|
||||
title,
|
||||
link: itemUrl,
|
||||
description: $d('.art-con').html() || $d('.textlive').html(),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
ctx.state.data = {
|
||||
title,
|
||||
link: url,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
@@ -22,6 +22,7 @@ module.exports = {
|
||||
'/miit/wjgs': ['Yoge-Code'],
|
||||
'/miit/zcjd': ['Yoge-Code'],
|
||||
'/moe/:type': ['Crawler995'],
|
||||
'/mofcom/article/:suffix+': ['LogicJake'],
|
||||
'/moj/aac/news/:type?': ['TonyRL'],
|
||||
'/nifdc/:path+': ['nczitzk'],
|
||||
'/nmpa/:path+': ['TonyRL'],
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
const cheerio = require('cheerio');
|
||||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
const host = 'http://www.mofcom.gov.cn';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const suffix = ctx.params.suffix;
|
||||
const url = `http://www.mofcom.gov.cn/article/${suffix}/`;
|
||||
const { data: res } = await got(url);
|
||||
const $ = cheerio.load(res);
|
||||
$('.listline').remove();
|
||||
const list = $('.txtList_01 li')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
const date =
|
||||
item.find('span').length !== 0
|
||||
? item
|
||||
.find('span')
|
||||
.text()
|
||||
.match(/((\d{4}-\d{2}-\d{2})(\s\d{2}:\d{2}:\d{2})?)/)[1]
|
||||
: item
|
||||
.find('a')
|
||||
.attr('title')
|
||||
.match(/(\d{4}年\d{1,2}月\d{1,2})/)[1];
|
||||
return {
|
||||
title: item.find('a').attr('title'),
|
||||
link: host + item.find('a').attr('href'),
|
||||
pubDate: timezone(parseDate(date, ['YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD', 'YYYY年M月D']), 8),
|
||||
};
|
||||
});
|
||||
|
||||
await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
let responses = await got(item.link);
|
||||
// xwfb/xwlxfbh || xwfb/xwztfbh
|
||||
const redirect = responses.data.match(/_cofing1=\{href:"(.*)",type/) || responses.data.match(/window\.location\.href='(.*)'/);
|
||||
if (redirect) {
|
||||
responses = await got(redirect[1], {
|
||||
headers: {
|
||||
Referer: item.link,
|
||||
},
|
||||
});
|
||||
}
|
||||
const $ = cheerio.load(responses.data);
|
||||
const iframe = $('.art-con iframe').attr('src');
|
||||
if ($('.art-con iframe').attr('src')) {
|
||||
const { data: res } = await got(iframe);
|
||||
item.description = cheerio.load(res)('tbody').html();
|
||||
} else {
|
||||
item.description = $('.art-con').html() || /* xwfb/xwztfbh */ $('.textlive').html();
|
||||
}
|
||||
item.pubDate = $('meta[name="PubDate"]').length ? timezone(parseDate($('meta[name="PubDate"]').attr('content'), 'YYYY-MM-DD HH:mm'), 8) : item.pubDate;
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
ctx.state.data = {
|
||||
title: $('head > title').text(),
|
||||
description: $('meta[name=description]').attr('content'),
|
||||
link: url,
|
||||
item: list,
|
||||
};
|
||||
};
|
||||
@@ -526,6 +526,17 @@ module.exports = {
|
||||
},
|
||||
],
|
||||
},
|
||||
'mofcom.gov.cn': {
|
||||
_name: '中华人民共和国商务部',
|
||||
'.': [
|
||||
{
|
||||
title: '新闻发布',
|
||||
docs: 'https://docs.rsshub.app/government.html#zhong-hua-ren-min-gong-he-guo-shang-wu-bu',
|
||||
source: ['/article/*'],
|
||||
target: (_, url) => `/gov/mofcom/article/${new URL(url).pathname.replace('/article/', '')}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
'moj.gov.tw': {
|
||||
_name: '台灣法務部廉政署',
|
||||
'www.aac': [
|
||||
|
||||
@@ -14,6 +14,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('/mofcom/article/:suffix+', require('./mofcom/article'));
|
||||
router.get('/moj/aac/news/:type?', require('./moj/aac/news'));
|
||||
router.get(/nifdc\/([\w/-]+)?/, require('./nifdc'));
|
||||
router.get(/\/nmpa\/([\w][\w/]+)?/, require('./nmpa/generic'));
|
||||
|
||||
Reference in New Issue
Block a user