mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-10 23:34:38 +08:00
fix(route): 中国工业和信息化部 (#8898)
* Update wjgs.js 更新了信息源 * Update wjgs.js * Update wjgs.js * Update wjgs.js * update miit cookie config * update cookie * Update wjgs.js * fix(route): miit wjgs zcjd Co-authored-by: Tony <TonyRL@users.noreply.github.com>
This commit is contained in:
@@ -1,53 +1,62 @@
|
|||||||
const got = require('@/utils/got');
|
const got = require('@/utils/got');
|
||||||
const cheerio = require('cheerio');
|
const cheerio = require('cheerio');
|
||||||
|
const { parseDate } = require('@/utils/parse-date');
|
||||||
|
const timezone = require('@/utils/timezone');
|
||||||
|
const baseUrl = 'https://www.miit.gov.cn';
|
||||||
|
const siteUrl = `${baseUrl}/zwgk/wjgs/index.html`;
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
const base_url = 'http://www.miit.gov.cn/n1146295/n7281310/';
|
const response = await got(siteUrl);
|
||||||
const response = await got.get(base_url);
|
|
||||||
const $ = cheerio.load(response.data);
|
const $ = cheerio.load(response.data);
|
||||||
const list = $('.clist_con li').get();
|
const buildStatic = $('script[parseType=buildstatic]');
|
||||||
|
const requestUrl = buildStatic.attr('url');
|
||||||
|
const queryData = JSON.parse(buildStatic.attr('querydata').replace(/'/g, '"'));
|
||||||
|
|
||||||
const ProcessFeed = (data) => {
|
const { data } = await got(`${baseUrl}${requestUrl}`, {
|
||||||
const $ = cheerio.load(data);
|
headers: {
|
||||||
|
referer: siteUrl,
|
||||||
|
},
|
||||||
|
searchParams: queryData,
|
||||||
|
});
|
||||||
|
const list = cheerio.load(data.data.html, null, false);
|
||||||
|
|
||||||
const content = $('p');
|
let items = list('.page-content ul li')
|
||||||
return content.html();
|
.toArray()
|
||||||
|
.map((item) => {
|
||||||
|
item = list(item);
|
||||||
|
return {
|
||||||
|
title: item.find('a').attr('title'),
|
||||||
|
link: new URL(item.find('a').attr('href'), baseUrl).href,
|
||||||
|
pubDate: parseDate(item.find('.fr').text(), 'YYYY-MM-DD'),
|
||||||
};
|
};
|
||||||
|
|
||||||
const items = await Promise.all(
|
|
||||||
list.map(async (item) => {
|
|
||||||
const $ = cheerio.load(item);
|
|
||||||
const $a = $('a');
|
|
||||||
let link = $a.attr('href');
|
|
||||||
if (link.startsWith('..')) {
|
|
||||||
link = base_url + link;
|
|
||||||
}
|
|
||||||
|
|
||||||
const cache = await ctx.cache.get(link);
|
|
||||||
if (cache) {
|
|
||||||
return Promise.resolve(JSON.parse(cache));
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await got({
|
|
||||||
method: 'get',
|
|
||||||
url: link,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const single = {
|
items = await Promise.all(
|
||||||
title: $a.text(),
|
items.map((item) =>
|
||||||
description: ProcessFeed(response.data),
|
ctx.cache.tryGet(item.link, async () => {
|
||||||
link,
|
const { data } = await got(item.link);
|
||||||
};
|
const $ = cheerio.load(data);
|
||||||
|
|
||||||
ctx.cache.set(link, JSON.stringify(single));
|
$('iframe').each((_, e) => {
|
||||||
return Promise.resolve(single);
|
e = $(e);
|
||||||
|
if (e.attr('src').startsWith('/')) {
|
||||||
|
e.attr('src', new URL(e.attr('src'), baseUrl).href);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
item.author = $('.cinfo')
|
||||||
|
.text()
|
||||||
|
.match(/来源:(.*)/)[1];
|
||||||
|
item.pubDate = timezone(parseDate($('#con_time').text(), 'YYYY-MM-DD HH:mm'), +8);
|
||||||
|
item.description = $('.ccontent').html();
|
||||||
|
|
||||||
|
return item;
|
||||||
})
|
})
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
ctx.state.data = {
|
ctx.state.data = {
|
||||||
title: '中国工业化和信息部',
|
title: `${$('head title').text()} - ${$('meta[name=SiteName]').attr('content')}`,
|
||||||
link: 'http://www.miit.gov.cn',
|
link: siteUrl,
|
||||||
description: '文件公示',
|
|
||||||
item: items,
|
item: items,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,53 +1,62 @@
|
|||||||
const got = require('@/utils/got');
|
const got = require('@/utils/got');
|
||||||
const cheerio = require('cheerio');
|
const cheerio = require('cheerio');
|
||||||
|
const { parseDate } = require('@/utils/parse-date');
|
||||||
|
const timezone = require('@/utils/timezone');
|
||||||
|
const baseUrl = 'https://www.miit.gov.cn';
|
||||||
|
const siteUrl = `${baseUrl}/zwgk/zcjd/index.html`;
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
const base_url = 'http://www.miit.gov.cn/n1146295/n7281315/';
|
const response = await got(siteUrl);
|
||||||
const response = await got.get(base_url);
|
|
||||||
const $ = cheerio.load(response.data);
|
const $ = cheerio.load(response.data);
|
||||||
const list = $('.clist_con li').get();
|
const buildStatic = $('script[parseType=buildstatic]');
|
||||||
|
const requestUrl = buildStatic.attr('url');
|
||||||
|
const queryData = JSON.parse(buildStatic.attr('querydata').replace(/'/g, '"'));
|
||||||
|
|
||||||
const ProcessFeed = (data) => {
|
const { data } = await got(`${baseUrl}${requestUrl}`, {
|
||||||
const $ = cheerio.load(data);
|
headers: {
|
||||||
|
referer: siteUrl,
|
||||||
|
},
|
||||||
|
searchParams: queryData,
|
||||||
|
});
|
||||||
|
const list = cheerio.load(data.data.html, null, false);
|
||||||
|
|
||||||
const content = $('p');
|
let items = list('.page-content ul li')
|
||||||
return content.html();
|
.toArray()
|
||||||
|
.map((item) => {
|
||||||
|
item = list(item);
|
||||||
|
return {
|
||||||
|
title: item.find('a').attr('title'),
|
||||||
|
link: new URL(item.find('a').attr('href'), baseUrl).href,
|
||||||
|
pubDate: parseDate(item.find('.fr').text(), 'YYYY-MM-DD'),
|
||||||
};
|
};
|
||||||
|
|
||||||
const items = await Promise.all(
|
|
||||||
list.map(async (item) => {
|
|
||||||
const $ = cheerio.load(item);
|
|
||||||
const $a = $('a');
|
|
||||||
let link = $a.attr('href');
|
|
||||||
if (link.startsWith('..')) {
|
|
||||||
link = base_url + link;
|
|
||||||
}
|
|
||||||
|
|
||||||
const cache = await ctx.cache.get(link);
|
|
||||||
if (cache) {
|
|
||||||
return Promise.resolve(JSON.parse(cache));
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await got({
|
|
||||||
method: 'get',
|
|
||||||
url: link,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const single = {
|
items = await Promise.all(
|
||||||
title: $a.text(),
|
items.map((item) =>
|
||||||
description: ProcessFeed(response.data),
|
ctx.cache.tryGet(item.link, async () => {
|
||||||
link,
|
const { data } = await got(item.link);
|
||||||
};
|
const $ = cheerio.load(data);
|
||||||
|
|
||||||
ctx.cache.set(link, JSON.stringify(single));
|
$('iframe').each((_, e) => {
|
||||||
return Promise.resolve(single);
|
e = $(e);
|
||||||
|
if (e.attr('src').startsWith('/')) {
|
||||||
|
e.attr('src', new URL(e.attr('src'), baseUrl).href);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
item.author = $('.cinfo')
|
||||||
|
.text()
|
||||||
|
.match(/来源:(.*)/)[1];
|
||||||
|
item.pubDate = timezone(parseDate($('#con_time').text(), 'YYYY-MM-DD HH:mm'), +8);
|
||||||
|
item.description = $('.ccontent').html();
|
||||||
|
|
||||||
|
return item;
|
||||||
})
|
})
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
ctx.state.data = {
|
ctx.state.data = {
|
||||||
title: '中国工业化和信息部',
|
title: `${$('head title').text()} - ${$('meta[name=SiteName]').attr('content')}`,
|
||||||
link: 'http://www.miit.gov.cn',
|
link: siteUrl,
|
||||||
description: '政策解读',
|
|
||||||
item: items,
|
item: items,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user