Add(route): add 律动BlockBeats (#8858)
This commit is contained in:
parent
e95a862a55
commit
87d3a04dfb
|
|
@ -2154,6 +2154,18 @@ column 为 third 时可选的 category:
|
|||
|
||||
<Route author="nczitzk" example="/6park/chan1/keywords/都市" path="/6park/:id/keywords/:keyword?" :paramsDesc="['分站,见上表', '关键字']"/>
|
||||
|
||||
## 律动
|
||||
|
||||
### 新闻快讯
|
||||
|
||||
<Route author="Fatpandac" example="/blockbeats/flash" path="/blockbeats/:channel?" :paramsDesc="['类型,见下表,默认为快讯']">
|
||||
|
||||
| 快讯 | 新闻 |
|
||||
| :---: | :--: |
|
||||
| flash | news |
|
||||
|
||||
</Route>
|
||||
|
||||
## 論盡媒體 AllAboutMacau Media
|
||||
|
||||
### 话题
|
||||
|
|
|
|||
|
|
@ -0,0 +1,50 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseRelativeDate } = require('@/utils/parse-date');
|
||||
|
||||
const rootUrl = 'https://www.theblockbeats.info';
|
||||
|
||||
const channelMap = {
|
||||
flash: '快讯',
|
||||
news: '新闻',
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const channel = ctx.params.channel ?? 'flash';
|
||||
|
||||
const response = await got.get(rootUrl);
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('div.news-item')
|
||||
.map((_, item) => {
|
||||
const title = $(item).find('a').attr('title');
|
||||
const link = rootUrl + $(item).find('a').attr('href');
|
||||
const pubDate = parseRelativeDate($(item).find('div.article-time').text());
|
||||
|
||||
return {
|
||||
title,
|
||||
link,
|
||||
pubDate,
|
||||
};
|
||||
})
|
||||
.filter((_, item) => item.title && item.link.includes(channel))
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got.get(item.link);
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.description = content(`div.${channel}-content`).html();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `TheBlockBeats - ${channelMap[channel]}`,
|
||||
link: rootUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/:channel?': ['Fatpandac'],
|
||||
};
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
module.exports = {
|
||||
'theblockbeats.info': {
|
||||
_name: '律动',
|
||||
rszhaopin: [
|
||||
{
|
||||
title: '快讯',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#lu-dong-xin-wen-kuai-xun',
|
||||
source: ['/'],
|
||||
target: '/blockbeats/flash',
|
||||
},
|
||||
{
|
||||
title: '新闻',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#lu-dong-xin-wen-kuai-xun',
|
||||
source: ['/'],
|
||||
target: '/blockbeats/news',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/:channel?', require('./index'));
|
||||
};
|
||||
Loading…
Reference in New Issue