mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-04 19:59:54 +08:00
fix(route): x6d (#11676)
This commit is contained in:
@@ -4189,7 +4189,9 @@ wechat-feeds 来源[已停止更新](https://github.com/hellodword/wechat-feeds/
|
||||
|
||||
## 小刀娱乐网
|
||||
|
||||
<Route author="nczitzk" example="/x6d/34" path="/x6d/:id?" :paramsDesc="['分类 id,可在对应分类页面的 URL 中找到,默认为首页最近更新']">
|
||||
### 分类
|
||||
|
||||
<Route author="nczitzk" example="/x6d/34" path="/x6d/:id?" :paramsDesc="['分类 id,可在对应分类页面的 URL 中找到,默认为首页最近更新']" radar="1">
|
||||
|
||||
| 技巧分享 | QQ 技巧 | 微信技巧 | 其他教程 | 其他分享 |
|
||||
| ---- | ----- | ---- | ---- | ---- |
|
||||
|
||||
@@ -3113,7 +3113,7 @@ router.get('/kongfz/shop/:id/:cat?', lazyloadRouteHandler('./routes/kongfz/shop'
|
||||
router.get('/xmind/mindmap/:lang?', lazyloadRouteHandler('./routes/xmind/mindmap'));
|
||||
|
||||
// 小刀娱乐网
|
||||
router.get('/x6d/:id?', lazyloadRouteHandler('./routes/x6d/index'));
|
||||
// router.get('/x6d/:id?', lazyloadRouteHandler('./routes/x6d/index'));
|
||||
|
||||
// 思维导图社区
|
||||
router.get('/edrawsoft/mindmap/:classId?/:order?/:sort?/:lang?/:price?/:search?', lazyloadRouteHandler('./routes/edrawsoft/mindmap'));
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
let currentUrl;
|
||||
let query;
|
||||
|
||||
ctx.params.id = ctx.params.id || 'latest';
|
||||
|
||||
if (ctx.params.id === 'latest') {
|
||||
currentUrl = 'https://www.x6d.com';
|
||||
} else {
|
||||
currentUrl = `https://www.x6d.com/html/${ctx.params.id}.html`;
|
||||
}
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
$('i.rj').remove();
|
||||
|
||||
if (ctx.params.id === 'latest') {
|
||||
query = $('#newslist ul').eq(0).find('li').not('.addd').find('a');
|
||||
} else {
|
||||
query = $('a.soft-title');
|
||||
}
|
||||
|
||||
const list = query
|
||||
.slice(0, 10)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.text(),
|
||||
link: `https://www.x6d.com${item.attr('href')}`,
|
||||
};
|
||||
})
|
||||
.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.article-content').html();
|
||||
item.pubDate = new Date(content('time').text() + ' GMT+8').toUTCString();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `小刀娱乐网 - ${$('title').text().split('-')[0]}`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
59
lib/v2/x6d/index.js
Normal file
59
lib/v2/x6d/index.js
Normal file
@@ -0,0 +1,59 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
const baseUrl = 'https://xd.x6d.com';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
let query;
|
||||
|
||||
const { id = 'latest' } = ctx.params;
|
||||
|
||||
const currentUrl = id === 'latest' ? baseUrl : `${baseUrl}/html/${id}.html`;
|
||||
|
||||
const { data: response } = await got(currentUrl);
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
$('i.rj').remove();
|
||||
|
||||
if (id === 'latest') {
|
||||
query = $('#newslist ul')
|
||||
.eq(0)
|
||||
.find('li')
|
||||
.not('.addd')
|
||||
.find('a')
|
||||
.slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 22);
|
||||
} else {
|
||||
query = $('a.soft-title').slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 10);
|
||||
}
|
||||
|
||||
const list = query.toArray().map((item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.text(),
|
||||
link: `${baseUrl}${item.attr('href')}`,
|
||||
};
|
||||
});
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data: detailResponse } = await got(item.link);
|
||||
const content = cheerio.load(detailResponse);
|
||||
|
||||
item.description = content('div.article-content').html();
|
||||
item.pubDate = timezone(parseDate(content('time').text()), 8);
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `小刀娱乐网 - ${$('title').text().split('-')[0]}`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
3
lib/v2/x6d/maintainer.js
Normal file
3
lib/v2/x6d/maintainer.js
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/:id?': ['nczitzk'],
|
||||
};
|
||||
13
lib/v2/x6d/radar.js
Normal file
13
lib/v2/x6d/radar.js
Normal file
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'x6d.com': {
|
||||
_name: '小刀娱乐网',
|
||||
xd: [
|
||||
{
|
||||
title: '最新',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#xiao-dao-yu-le-wang',
|
||||
source: ['/html/:id'],
|
||||
target: (params) => `/x6d/${params.id.replace('.html', '')}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
3
lib/v2/x6d/router.js
Normal file
3
lib/v2/x6d/router.js
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/:id?', require('./index'));
|
||||
};
|
||||
Reference in New Issue
Block a user