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:
parent
05e49f4f56
commit
f083bf4e49
|
|
@ -1083,6 +1083,42 @@ IT・科学 tech_science
|
|||
|
||||
</Route>
|
||||
|
||||
## 广州日报
|
||||
|
||||
### 客户端
|
||||
|
||||
<Route author="TimWu007" example="/gzdaily/app/74" path="/gzdaily/app/:column?" :paramsDesc="['栏目 ID,点击对应栏目后在地址栏找到']">
|
||||
|
||||
::: tip 提示
|
||||
|
||||
在北京时间深夜可能无法获取内容。
|
||||
|
||||
:::
|
||||
|
||||
常用栏目 ID:
|
||||
|
||||
| 栏目名 | ID |
|
||||
| ------ | ---- |
|
||||
| 首页 | 74 |
|
||||
| 时局 | 374 |
|
||||
| 广州 | 371 |
|
||||
| 大湾区 | 397 |
|
||||
| 城区 | 2980 |
|
||||
|
||||
</Route>
|
||||
|
||||
### 新花城(广州市融媒体中心)
|
||||
|
||||
<Route author="TimWu007" example="/gzdaily/cmc/shouye" path="/gzdaily/cmc/:channel?" :paramsDesc="['频道名']">
|
||||
|
||||
::: tip 提示
|
||||
|
||||
`频道名(channel)` 可在对应频道 url 后的参数中获取,如 `首页` 的栏目 url 为`https://huacheng.gz-cmc.com/channel/shouye/index.html`, `频道名` 即为 `shouye`。
|
||||
|
||||
:::
|
||||
|
||||
</Route>
|
||||
|
||||
## 国际金融报栏目
|
||||
|
||||
### 栏目
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
};
|
||||
|
|
@ -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,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = {
|
||||
'/app/:column?': ['TimWu007'],
|
||||
'/cmc/:channel?': ['TimWu007'],
|
||||
};
|
||||
|
|
@ -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: ['/'],
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/app/:column?', require('./app'));
|
||||
router.get('/cmc/:channel?', require('./cmc'));
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{{ if thumb }}
|
||||
<img src="{{ thumb }}"><br>
|
||||
{{ /if }}
|
||||
Loading…
Reference in New Issue