Skip to content

Commit

Permalink
Merge pull request #1299 from DIYgod/master
Browse files Browse the repository at this point in the history
[pull] master from diygod:master
  • Loading branch information
pull[bot] authored Dec 24, 2023
2 parents af30a68 + 30ed60d commit c8aa779
Show file tree
Hide file tree
Showing 20 changed files with 425 additions and 40 deletions.
4 changes: 1 addition & 3 deletions lib/middleware/onerror.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ if (config.sentry.dsn) {
Sentry.init({
dsn: config.sentry.dsn,
});
Sentry.configureScope((scope) => {
scope.setTag('node_name', config.nodeName);
});
Sentry.getCurrentScope().setTag('node_name', config.nodeName);

logger.info('Sentry inited.');
}
Expand Down
1 change: 1 addition & 0 deletions lib/v2/consumer/maintainer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
module.exports = {
'/shopping-guide/:category?/:language?': ['TonyRL'],
'/:category?/:language?/:keyword?': ['nczitzk'],
};
6 changes: 6 additions & 0 deletions lib/v2/consumer/radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ module.exports = {
source: ['/'],
target: '/consumer/:category?/:language?/:keyword?',
},
{
title: '消費全攻略',
docs: 'https://docs.rsshub.app/routes/new-media#xiao-fei-zhe-wei-yuan-hui',
source: ['/:language/shopping-guide/:category'],
target: '/consumer/shopping-guide/:category/:language',
},
],
},
};
1 change: 1 addition & 0 deletions lib/v2/consumer/router.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
module.exports = function (router) {
router.get('/shopping-guide/:category?/:language?', require('./shopping-guide'));
router.get('/:category?/:language?/:keyword?', require('./index'));
};
66 changes: 66 additions & 0 deletions lib/v2/consumer/shopping-guide.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');

module.exports = async (ctx) => {
const { category = 'trivia', language = 'tc' } = ctx.params;
const rootUrl = 'https://www.consumer.org.hk';
const currentUrl = `${rootUrl}/${language}/shopping-guide/${category}`;

const { data: response } = await got(currentUrl, {
headers: {
cookie: `consumer_pagination={${encodeURI('"228c"')}:24}`,
},
});

const $ = cheerio.load(response);

const list = $('.shadow-long-blk')
.toArray()
.map((item) => {
item = $(item);

const info = item
.find('.item-info li')
.toArray()
.map((item) => $(item).text().trim());
return {
title: item.find('h2').text().trim(),
description: item.find('p').text().trim(),
link: `${rootUrl}${item.attr('href')}`,
pubDate: parseDate(info.shift(), 'YYYY-MM-DD'),
category: info,
};
});

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);

const header = $('.article-img-blk');
header.find('img').each((_, ele) => {
ele = $(ele);
if (ele.attr('src') && ele.attr('srcset')) {
ele.removeAttr('srcset');
ele.attr('src', ele.attr('src').replace(/\/\d+c\d+\//, '/0p0/'));
}
});

item.description = header.html() + $('article .ckec').html();

return item;
})
)
);

ctx.state.data = {
title: $('head title').text(),
link: currentUrl,
image: $('meta[property="og:image"]').attr('content'),
logo: $('link[rel="apple-touch-icon"]').attr('href'),
icon: $('link[rel="apple-touch-icon"]').attr('href'),
item: items,
};
};
9 changes: 8 additions & 1 deletion lib/v2/dcfever/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const parseItem = (item, tryGet) =>
tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = cheerio.load(response);
const content = $('div[itemprop="articleBody"]');
const content = $('div[itemprop="articleBody"], .column_article_content_html');

const pageLinks = $('.article_multi_page a')
.not('.selected')
Expand Down Expand Up @@ -41,6 +41,13 @@ const parseItem = (item, tryGet) =>
}
});

content.find('iframe').each((_, e) => {
e = $(e);
if (e.attr('src').startsWith('https://www.facebook.com/plugins/like.php')) {
e.remove();
}
});

item.description = content.html();
item.pubDate = parseDate($('meta[property="article:published_time"]').attr('content'));

Expand Down
59 changes: 59 additions & 0 deletions lib/v2/gov/jgjcndrc/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');

module.exports = async (ctx) => {
const { id = 'sytzgg' } = ctx.params;
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 30;

const rootUrl = 'http://www.jgjcndrc.org.cn';
const currentUrl = new URL(`list.aspx?clmId=${id}`, rootUrl).href;

const { data: response } = await got(currentUrl);

const $ = cheerio.load(response);

let items = $('ul.list_02 li.li a[title]')
.slice(0, limit)
.toArray()
.map((item) => {
item = $(item);

return {
title: item.text(),
link: new URL(item.prop('href'), rootUrl).href,
pubDate: parseDate(item.prev().text()),
};
});

items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);

const content = cheerio.load(detailResponse);

item.title = content('div.txt_title1').text();
item.description = content('div#zoom').html();
item.pubDate = parseDate(content('div.txt_subtitle1').text().trim());

return item;
})
)
);

const author = $('title').text();
const subtitle = $('li.L').first().text();
const image = new URL($('img.logo2').prop('src'), rootUrl).href;

ctx.state.data = {
item: items,
title: `${author} - ${subtitle}`,
link: currentUrl,
description: author,
language: $('html').prop('lang'),
image,
subtitle,
author,
};
};
1 change: 1 addition & 0 deletions lib/v2/gov/maintainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module.exports = {
'/fmprc/:category?': ['nicolaszf', 'nczitzk'],
'/forestry/gjlckjdjt/:category?': ['nczitzk'],
'/immiau/news': ['liu233w'],
'/jgjcndrc/:id?': ['nczitzk'],
'/jinan/healthcommission/medical_exam_notice': ['tzjyxb'],
'/mee/ywdt/:category?': ['liuxsdev'],
'/mem/gk/sgcc/:category?': ['nczitzk'],
Expand Down
148 changes: 148 additions & 0 deletions lib/v2/gov/radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,154 @@ module.exports = {
},
],
},
'jgjcndrc.org.cn': {
_name: '中华人民共和国国家发展和改革委员会价格监测中心',
'.': [
{
title: '栏目',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-guo-jia-fa-zhan-he-gai-ge-wei-yuan-hui-jia-ge-jian-ce-zhong-xin',
source: ['/list.aspx', '/list1.aspx', '/list2.aspx', '/list3.aspx'],
target: (_, url) => {
url = new URL(url);
const id = url.searchParams.get('id');

return `/gov/jgjcndrc${id ? `/${id}` : ''}`;
},
},
{
title: '通知公告',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-guo-jia-fa-zhan-he-gai-ge-wei-yuan-hui-jia-ge-jian-ce-zhong-xin',
source: ['/list.aspx', '/list1.aspx', '/list2.aspx', '/list3.aspx'],
target: '/gov/jgjcndrc/692',
},
{
title: '中心工作动态',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-guo-jia-fa-zhan-he-gai-ge-wei-yuan-hui-jia-ge-jian-ce-zhong-xin',
source: ['/list.aspx', '/list1.aspx', '/list2.aspx', '/list3.aspx'],
target: '/gov/jgjcndrc/693',
},
{
title: '地方工作动态',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-guo-jia-fa-zhan-he-gai-ge-wei-yuan-hui-jia-ge-jian-ce-zhong-xin',
source: ['/list.aspx', '/list1.aspx', '/list2.aspx', '/list3.aspx'],
target: '/gov/jgjcndrc/694',
},
{
title: '监测信息',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-guo-jia-fa-zhan-he-gai-ge-wei-yuan-hui-jia-ge-jian-ce-zhong-xin',
source: ['/list.aspx', '/list1.aspx', '/list2.aspx', '/list3.aspx'],
target: '/gov/jgjcndrc/695',
},
{
title: '分析预测',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-guo-jia-fa-zhan-he-gai-ge-wei-yuan-hui-jia-ge-jian-ce-zhong-xin',
source: ['/list.aspx', '/list1.aspx', '/list2.aspx', '/list3.aspx'],
target: '/gov/jgjcndrc/696',
},
{
title: '调查报告',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-guo-jia-fa-zhan-he-gai-ge-wei-yuan-hui-jia-ge-jian-ce-zhong-xin',
source: ['/list.aspx', '/list1.aspx', '/list2.aspx', '/list3.aspx'],
target: '/gov/jgjcndrc/697',
},
{
title: '价格指数',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-guo-jia-fa-zhan-he-gai-ge-wei-yuan-hui-jia-ge-jian-ce-zhong-xin',
source: ['/list.aspx', '/list1.aspx', '/list2.aspx', '/list3.aspx'],
target: '/gov/jgjcndrc/698',
},
{
title: '地方价格监测',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-guo-jia-fa-zhan-he-gai-ge-wei-yuan-hui-jia-ge-jian-ce-zhong-xin',
source: ['/list.aspx', '/list1.aspx', '/list2.aspx', '/list3.aspx'],
target: '/gov/jgjcndrc/699',
},
{
title: '价格监测报告制度',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-guo-jia-fa-zhan-he-gai-ge-wei-yuan-hui-jia-ge-jian-ce-zhong-xin',
source: ['/list.aspx', '/list1.aspx', '/list2.aspx', '/list3.aspx'],
target: '/gov/jgjcndrc/700',
},
{
title: '监测法规',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-guo-jia-fa-zhan-he-gai-ge-wei-yuan-hui-jia-ge-jian-ce-zhong-xin',
source: ['/list.aspx', '/list1.aspx', '/list2.aspx', '/list3.aspx'],
target: '/gov/jgjcndrc/701',
},
{
title: '媒体聚焦',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-guo-jia-fa-zhan-he-gai-ge-wei-yuan-hui-jia-ge-jian-ce-zhong-xin',
source: ['/list.aspx', '/list1.aspx', '/list2.aspx', '/list3.aspx'],
target: '/gov/jgjcndrc/753',
},
{
title: '国内外市场价格监测情况周报',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-guo-jia-fa-zhan-he-gai-ge-wei-yuan-hui-jia-ge-jian-ce-zhong-xin',
source: ['/list.aspx', '/list1.aspx', '/list2.aspx', '/list3.aspx'],
target: '/gov/jgjcndrc/749',
},
{
title: '主要粮油副食品日报',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-guo-jia-fa-zhan-he-gai-ge-wei-yuan-hui-jia-ge-jian-ce-zhong-xin',
source: ['/list.aspx', '/list1.aspx', '/list2.aspx', '/list3.aspx'],
target: '/gov/jgjcndrc/703',
},
{
title: '生猪出厂价与玉米价格周报',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-guo-jia-fa-zhan-he-gai-ge-wei-yuan-hui-jia-ge-jian-ce-zhong-xin',
source: ['/list.aspx', '/list1.aspx', '/list2.aspx', '/list3.aspx'],
target: '/gov/jgjcndrc/704',
},
{
title: '国际市场石油价格每日动态',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-guo-jia-fa-zhan-he-gai-ge-wei-yuan-hui-jia-ge-jian-ce-zhong-xin',
source: ['/list.aspx', '/list1.aspx', '/list2.aspx', '/list3.aspx'],
target: '/gov/jgjcndrc/705',
},
{
title: '非学科类培训服务价格',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-guo-jia-fa-zhan-he-gai-ge-wei-yuan-hui-jia-ge-jian-ce-zhong-xin',
source: ['/list.aspx', '/list1.aspx', '/list2.aspx', '/list3.aspx'],
target: '/gov/jgjcndrc/821',
},
{
title: '监测周期价格动态',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-guo-jia-fa-zhan-he-gai-ge-wei-yuan-hui-jia-ge-jian-ce-zhong-xin',
source: ['/list.aspx', '/list1.aspx', '/list2.aspx', '/list3.aspx'],
target: '/gov/jgjcndrc/706',
},
{
title: '月度监测行情表',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-guo-jia-fa-zhan-he-gai-ge-wei-yuan-hui-jia-ge-jian-ce-zhong-xin',
source: ['/list.aspx', '/list1.aspx', '/list2.aspx', '/list3.aspx'],
target: '/gov/jgjcndrc/707',
},
{
title: '猪料、鸡料、蛋料比价',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-guo-jia-fa-zhan-he-gai-ge-wei-yuan-hui-jia-ge-jian-ce-zhong-xin',
source: ['/list.aspx', '/list1.aspx', '/list2.aspx', '/list3.aspx'],
target: '/gov/jgjcndrc/708',
},
{
title: '全国钢材批发市场价格周报',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-guo-jia-fa-zhan-he-gai-ge-wei-yuan-hui-jia-ge-jian-ce-zhong-xin',
source: ['/list.aspx', '/list1.aspx', '/list2.aspx', '/list3.aspx'],
target: '/gov/jgjcndrc/739',
},
{
title: '全国成品油批发市场价格周报',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-guo-jia-fa-zhan-he-gai-ge-wei-yuan-hui-jia-ge-jian-ce-zhong-xin',
source: ['/list.aspx', '/list1.aspx', '/list2.aspx', '/list3.aspx'],
target: '/gov/jgjcndrc/740',
},
{
title: '线上价格监测',
docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-guo-jia-fa-zhan-he-gai-ge-wei-yuan-hui-jia-ge-jian-ce-zhong-xin',
source: ['/list.aspx', '/list1.aspx', '/list2.aspx', '/list3.aspx'],
target: '/gov/jgjcndrc/822',
},
],
},
'jinan.gov.cn': {
_name: '济南市卫生健康委员会',
jnmhc: [
Expand Down
1 change: 1 addition & 0 deletions lib/v2/gov/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module.exports = function (router) {
router.get('/fmprc/:category?', require('./mfa/wjdt'));
router.get('/forestry/gjlckjdjt/:category?', require('./forestry/gjlckjdjt'));
router.get('/immiau/news', require('./immiau/news'));
router.get('/jgjcndrc/:id?', require('./jgjcndrc'));
router.get('/jinan/healthcommission/medical_exam_notice', require('./jinan/healthcommission/medical_exam_notice'));
router.get('/mee/ywdt/:category?', require('./mee/ywdt'));
router.get('/mem/gk/sgcc/:category?', require('./mem/sgcc'));
Expand Down
3 changes: 3 additions & 0 deletions lib/v2/pkmer/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/recent': ['Gnoyong'],
};
13 changes: 13 additions & 0 deletions lib/v2/pkmer/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
'pkmer.cn': {
_name: 'PKMer',
'.': [
{
title: '最近更新',
docs: 'https://docs.rsshub.app/routes/bbs#pkmer-zui-jin-geng-xin',
source: ['/page/*'],
target: '/pkmer/recent',
},
],
},
};
Loading

0 comments on commit c8aa779

Please sign in to comment.