feat(route): Add 广州日报客户端、新花城 (#12162)

* feat(route): add Guangzhou Daily (APP) 广州日报(客户端)

* feat(route): Add 新花城(广州市融媒体中心)

* Update lib/v2/gzdaily/app.js

* Update lib/v2/gzdaily/cmc.js

* Update lib/v2/gzdaily/cmc.js

* Update lib/v2/gzdaily/router.js

* Update lib/v2/gzdaily/maintainer.js

* Update docs/traditional-media.md

* Update docs/traditional-media.md

* Update lib/v2/gzdaily/radar.js

* Update lib/v2/gzdaily/radar.js

* Update lib/v2/gzdaily/app.js

* Update gzdaily

---------
This commit is contained in:
Tim Wu
2023-03-24 21:48:37 +08:00
committed by GitHub
parent 05e49f4f56
commit f083bf4e49
7 changed files with 182 additions and 0 deletions
+53
View File
@@ -0,0 +1,53 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const timezone = require('@/utils/timezone');
const { parseDate } = require('@/utils/parse-date');
const { art } = require('@/utils/render');
const path = require('path');
module.exports = async (ctx) => {
const column = ctx.params.column ?? 74;
const currentUrl = `https://app.gzdaily.cn/app_if/getArticles?columnId=${column}&page=1`;
const { data: response } = await got(currentUrl);
const list = response.list
.filter((i) => i.newstype === 0) // Remove special report (专题) and articles from Guangzhou Converged Media Center (新花城).
.map((item) => ({
title: item.title,
description: art(path.join(__dirname, 'templates/description.art'), {
thumb: item.picBig,
}),
pubDate: timezone(parseDate(item.publishtime), +8),
link: item.shareUrl,
colName: item.colName,
author: item.arthorName,
}));
let colName = '';
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
});
const content = cheerio.load(detailResponse.data);
colName = colName === '' ? item.colName : colName;
if (content('.abstract').text()) {
content('.abstract').find('span').remove();
item.description += '<blockquote>' + content('.abstract').text() + '</blockquote>';
}
item.description += content('.article').html() ?? '';
return item;
})
)
);
ctx.state.data = {
title: `广州日报客户端 - ${colName}`,
link: `https://www.gzdaily.cn/amucsite/web/index.html#/home/${column}`,
item: items,
};
};
+60
View File
@@ -0,0 +1,60 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const timezone = require('@/utils/timezone');
const { parseDate } = require('@/utils/parse-date');
const { art } = require('@/utils/render');
const path = require('path');
module.exports = async (ctx) => {
const channel = ctx.params.channel ?? 'shouye';
const currentUrl = `https://huacheng.gz-cmc.com/channel/${channel}/index.html`;
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
const title = $('a.brand').text().trim();
let items = $('.news-list-row2')
.toArray()
.filter((item) => $(item).attr('contenttype') === '1' && $(item).attr('mlistpattern') === '1')
.map((item) => {
item = $(item);
return {
title: item.text().replace(/\s*/g, ''),
link: item.children('a').attr('href'),
description: art(path.join(__dirname, 'templates/description.art'), {
thumb: item.find('img').attr('src'),
}),
};
});
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
});
const content = cheerio.load(detailResponse.data);
content('.broadcast-container').remove();
item.description += content('.article-source').html() ?? '';
item.description += content('#articleContent').html();
item.title = content('title').text();
item.author = content('meta[name="author"]').attr('content');
item.pubDate = timezone(parseDate(content('.article-time').text()), +8);
return item;
})
)
);
ctx.state.data = {
title: `广州日报新花城 - ${title}`,
link: currentUrl,
item: items,
};
};
+4
View File
@@ -0,0 +1,4 @@
module.exports = {
'/app/:column?': ['TimWu007'],
'/cmc/:channel?': ['TimWu007'],
};
+22
View File
@@ -0,0 +1,22 @@
module.exports = {
'gzdaily.cn': {
_name: '广州日报',
'.': [
{
title: '客户端',
docs: 'https://docs.rsshub.app/traditional-media.html#guang-zhou-ri-bao',
source: ['/'],
},
],
},
'gz-cmc.com': {
_name: '广州日报',
huacheng: [
{
title: '新花城(广州市融媒体中心)',
docs: 'https://docs.rsshub.app/traditional-media.html#guang-zhou-ri-bao',
source: ['/'],
},
],
},
};
+4
View File
@@ -0,0 +1,4 @@
module.exports = (router) => {
router.get('/app/:column?', require('./app'));
router.get('/cmc/:channel?', require('./cmc'));
};
+3
View File
@@ -0,0 +1,3 @@
{{ if thumb }}
<img src="{{ thumb }}"><br>
{{ /if }}