feat(route): add 衡阳日报 & 衡阳晚报 (#9418)
* feat(route): add 衡阳日报 & 衡阳晚报 * docs: update category
This commit is contained in:
parent
f3aa4c5677
commit
d88e52ce8e
|
|
@ -298,6 +298,7 @@ pageClass: routes
|
|||
在 Stork 上注册并订阅关键词后,在 `我的` -> `关键词` 中可找到对应关键词的订阅 URL。URL 后的两个参数即为路由参数。
|
||||
|
||||
</Route>
|
||||
|
||||
## X-MOL 平台
|
||||
|
||||
### 期刊
|
||||
|
|
|
|||
|
|
@ -837,6 +837,44 @@ Type 栏目:
|
|||
|
||||
</Route>
|
||||
|
||||
## 衡阳全搜索
|
||||
|
||||
### 衡阳日报
|
||||
|
||||
<Route author="nczitzk" example="/hyqss/hyrb" path="/hyqss/hyrb/:id?" :paramsDesc="['编号,见下表,默认为全部']">
|
||||
|
||||
| 版 | 编号 |
|
||||
| ----------- | -- |
|
||||
| 全部 | |
|
||||
| 第 A01 版:版面一 | 1 |
|
||||
| 第 A02 版:版面二 | 2 |
|
||||
| 第 A03 版:版面三 | 3 |
|
||||
| 第 A04 版:版面四 | 4 |
|
||||
| 第 A05 版:版面五 | 5 |
|
||||
| 第 A06 版:版面六 | 6 |
|
||||
| 第 A07 版:版面七 | 7 |
|
||||
| 第 A08 版:版面八 | 8 |
|
||||
|
||||
</Route>
|
||||
|
||||
### 衡阳晚报
|
||||
|
||||
<Route author="nczitzk" example="/hyqss/hywb" path="/hyqss/hywb/:id?" :paramsDesc="['编号,见下表,默认为全部']">
|
||||
|
||||
| 版 | 编号 |
|
||||
| ----------- | -- |
|
||||
| 全部 | |
|
||||
| 第 A01 版:版面一 | 1 |
|
||||
| 第 A02 版:版面二 | 2 |
|
||||
| 第 A03 版:版面三 | 3 |
|
||||
| 第 A04 版:版面四 | 4 |
|
||||
| 第 A05 版:版面五 | 5 |
|
||||
| 第 A06 版:版面六 | 6 |
|
||||
| 第 A07 版:版面七 | 7 |
|
||||
| 第 A08 版:版面八 | 8 |
|
||||
|
||||
</Route>
|
||||
|
||||
## 华尔街见闻
|
||||
|
||||
### 华尔街见闻
|
||||
|
|
|
|||
|
|
@ -0,0 +1,89 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const type = ctx.params.type ?? 'hyrb';
|
||||
const isDaily = type === 'hyrb';
|
||||
|
||||
const id = ctx.params.id;
|
||||
|
||||
const rootUrl = 'http://epaper.hyqss.cn';
|
||||
const currentUrl = `${rootUrl}${isDaily ? '' : `/${type}`}`;
|
||||
|
||||
let response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const url = response.data.match(/URL=(.*)"/)[1];
|
||||
|
||||
response = await got({
|
||||
method: 'get',
|
||||
url: `${currentUrl}/${id ? url.replace(/node_\d+\.htm/, `node_19${isDaily ? '62' : '74'}${id}.htm`) : url}`,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const matches = url.match(/html\/(.*)\/node/);
|
||||
const link = `${rootUrl}/${isDaily ? '' : 'hywb/'}html/${matches[1]}`;
|
||||
|
||||
let items = $('#main-ed-articlenav-list')
|
||||
.first()
|
||||
.find('a')
|
||||
.toArray()
|
||||
.map((a) => `${link}/${$(a).attr('href')}`);
|
||||
|
||||
if (!id) {
|
||||
await Promise.all(
|
||||
$('#bmdhTable')
|
||||
.find('#pageLink')
|
||||
.toArray()
|
||||
.map((p) => `${link}/${$(p).attr('href')}`)
|
||||
.map(async (p) => {
|
||||
const pageResponse = await got({
|
||||
method: 'get',
|
||||
url: p,
|
||||
});
|
||||
|
||||
const page = cheerio.load(pageResponse.data);
|
||||
|
||||
items.push(
|
||||
...page('#main-ed-articlenav-list')
|
||||
.first()
|
||||
.find('a')
|
||||
.toArray()
|
||||
.map((a) => `${link}/${page(a).attr('href')}`)
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
items = await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
return {
|
||||
link: item,
|
||||
title: content('.font01').text(),
|
||||
description: content('#ozoom').html(),
|
||||
pubDate: timezone(parseDate(matches[1], 'YYYY-MM/DD'), +8),
|
||||
};
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `衡阳${isDaily ? '日' : '晚'}报${id ? ` - ${$('strong').first().parent().text()}` : ''}`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
allowEmpty: true,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = {
|
||||
'/hyrb/:id?': ['nczitzk'],
|
||||
'/hywb/:id?': ['nczitzk'],
|
||||
};
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
const radars = [
|
||||
{
|
||||
title: '衡阳日报',
|
||||
docs: 'https://docs.rsshub.app/journal.html#heng-yang-quan-sou-suo-heng-yang-ri-bao',
|
||||
source: ['/'],
|
||||
target: '/hnrb/hyrb/:id?',
|
||||
},
|
||||
{
|
||||
title: '衡阳晚报',
|
||||
docs: 'https://docs.rsshub.app/journal.html#heng-yang-quan-sou-suo-heng-yang-wan-bao',
|
||||
source: ['/'],
|
||||
target: '/hnrb/hywb/:id?',
|
||||
},
|
||||
];
|
||||
|
||||
module.exports = {
|
||||
'hyqss.cn': {
|
||||
_name: '衡阳全搜索',
|
||||
'.': radars,
|
||||
epaper: radars,
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/:type?/:id?', require('./index'));
|
||||
};
|
||||
Loading…
Reference in New Issue