feat(route): xiaozhuanlan (#9848)
This commit is contained in:
@@ -3723,6 +3723,12 @@ wechat-feeds 来源[已停止更新](https://github.com/hellodword/wechat-feeds/
|
||||
|
||||
</Route>
|
||||
|
||||
## 小专栏
|
||||
|
||||
### 专栏
|
||||
|
||||
<Route author="TonyRL" example="/xiaozhuanlan/column/olddriver-selection" path="/xiaozhuanlan/column/:id" :paramsDesc="['专栏 ID,可在专栏页 URL 中找到']" radar="1" rssbud="1" />
|
||||
|
||||
## 辛華社
|
||||
|
||||
### 首页
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const md = require('markdown-it')({
|
||||
linkify: true,
|
||||
});
|
||||
const baseUrl = 'https://xiaozhuanlan.com';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { id } = ctx.params;
|
||||
const response = await got(`${baseUrl}/${id}`);
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
let items = $('.xzl-topic-item')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
item.find('.topic-has-suggested-item').remove();
|
||||
return {
|
||||
title: item.find('h3').text().trim(),
|
||||
link: new URL(item.find('.topic-body-link').attr('href'), baseUrl).href,
|
||||
author: item.find('.topic-header .xzl-author-lockup').text().trim(),
|
||||
pubDate: parseDate(item.find('.topic-header .timeago').attr('title')),
|
||||
};
|
||||
});
|
||||
|
||||
items = await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got(item.link);
|
||||
const $ = cheerio.load(detailResponse.data);
|
||||
|
||||
item.description = md.render($('.hidden_markdown_body').attr('data-summary'));
|
||||
if ($('.topic-tags')) {
|
||||
item.category = $('.topic-tags label')
|
||||
.toArray()
|
||||
.map((l) => $(l).text());
|
||||
}
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('head title').text().trim(),
|
||||
link: `${baseUrl}/${id}`,
|
||||
description: $('meta[name=description]').attr('content'),
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/column/:id': ['TonyRL'],
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'xiaozhuanlan.com': {
|
||||
_name: '小专栏',
|
||||
'.': [
|
||||
{
|
||||
title: '专栏',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#xiao-zhuan-lan',
|
||||
source: '/:id',
|
||||
target: '/xiaozhuanlan/column/:id',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/column/:id', require('./column'));
|
||||
};
|
||||
Reference in New Issue
Block a user