feat(route): add 辛華社 (#8357)
This commit is contained in:
parent
beebfa91a3
commit
3715f2b35e
|
|
@ -2800,6 +2800,32 @@ column 为 third 时可选的 category:
|
|||
|
||||
<Route author="nczitzk" example="/news/whxw" path="/news/whxw"/>
|
||||
|
||||
## 辛華社
|
||||
|
||||
### 首页
|
||||
|
||||
<Route author="nczitzk" example="/hotchina" path="/hotchina"/>
|
||||
|
||||
### 分类
|
||||
|
||||
<Route author="nczitzk" example="/hotchina" path="/hotchina/category/:id?" :paramsDesc="['分类,见下表,默认为首页']">
|
||||
|
||||
| 攝徒日記 | 辛華社特約報導 | 小粉紅觀察 | 維權消息 | 讀者投書 | 中國牆內 | 台灣國 | 國際 |
|
||||
| -------- | -------------- | ---------- | -------- | -------- | -------- | ------ | ---- |
|
||||
|
||||
</Route>
|
||||
|
||||
### 标签
|
||||
|
||||
<Route author="nczitzk" example="/hotchina" path="/hotchina/tag/:id?" :paramsDesc="['标签,可在对应标签页的 URL 中找到,默认为首页']">
|
||||
|
||||
以下为 Top Tags:
|
||||
|
||||
| 辱華 | 小粉紅 | 中國限電 | 徵稿 | 特約報導 | 舔共藝人 | 中共國慶 |
|
||||
| ---- | ------ | -------- | ---- | -------- | -------- | -------- |
|
||||
|
||||
</Route>
|
||||
|
||||
## 新浪专栏
|
||||
|
||||
### 创事记
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category ?? '';
|
||||
const id = ctx.params.id ?? '';
|
||||
|
||||
const rootUrl = 'https://hotchina.news';
|
||||
const currentUrl = `${rootUrl}${category && id ? `/archives/${category}/${id}` : ''}`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('.title')
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
|
||||
const a = item.find('a');
|
||||
|
||||
return {
|
||||
title: a.text(),
|
||||
link: a.attr('href'),
|
||||
pubDate: parseDate(item.next().find('.mg-blog-date').text().trim(), 'M 月 D, YYYY'),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
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);
|
||||
|
||||
item.description = content('div[itemprop="articleBody"]').html();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
module.exports = {
|
||||
'/': ['nczitzk'],
|
||||
'/category/:id?': ['nczitzk'],
|
||||
'/tag/:id?': ['nczitzk'],
|
||||
};
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
module.exports = {
|
||||
'hotchina.news': {
|
||||
_name: '辛華社',
|
||||
'.': [
|
||||
{
|
||||
title: '首页',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#xin-hua-she-shou-ye',
|
||||
source: ['/'],
|
||||
target: '/hotchina',
|
||||
},
|
||||
{
|
||||
title: '分类',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#xin-hua-she-fen-lei',
|
||||
source: ['/archives/category/:id', '/'],
|
||||
target: '/hotchina/category/:id?',
|
||||
},
|
||||
{
|
||||
title: '标签',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#xin-hua-she-biao-qian',
|
||||
source: ['/archives/tag/:id', '/'],
|
||||
target: '/hotchina/tag/:id?',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/:category?/:id?', require('./index'));
|
||||
};
|
||||
Loading…
Reference in New Issue