mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
@@ -298,6 +298,18 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的
|
||||
|
||||
<Route author="DIYgod" example="/mhw/news" path="/mhw/news" radar="1"/>
|
||||
|
||||
## 剑网 3
|
||||
|
||||
### 新闻资讯
|
||||
|
||||
<Route author="nczitzk" example="/jx3" path="/jx3/:caty?" :paramsDesc="['分类,见下表,默认为最新']">
|
||||
|
||||
| 最新 | 新闻 | 活动 | 公告 |
|
||||
| ------- | ----- | ---- | -------- |
|
||||
| allnews | press | hd | announce |
|
||||
|
||||
</Route>
|
||||
|
||||
## 旅法师营地
|
||||
|
||||
### 旅法师营地
|
||||
|
||||
@@ -3219,6 +3219,9 @@ router.get('/feixuew/:id?', require('./routes/feixuew/index'));
|
||||
// 1X
|
||||
router.get('/1x/:type?/:caty?', require('./routes/1x/index'));
|
||||
|
||||
// 剑网3
|
||||
router.get('/jx3/:caty?', require('./routes/jx3/news'));
|
||||
|
||||
// GQ
|
||||
router.get('/gq/tw/:caty?/:subcaty?', require('./routes/gq/tw/index'));
|
||||
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
const url = require('url');
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
ctx.params.caty = ctx.params.caty || 'allnews';
|
||||
|
||||
let query;
|
||||
|
||||
if (ctx.params.caty === 'hd') {
|
||||
query = 'div.article_list article div h3 a';
|
||||
} else {
|
||||
query = 'div.article_list ul li a';
|
||||
}
|
||||
|
||||
const rootUrl = 'https://jx3.xoyo.com';
|
||||
const currentUrl = `${rootUrl}/${ctx.params.caty}`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $(query)
|
||||
.slice(0, 10)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.text(),
|
||||
link: url.resolve(rootUrl, item.attr('href')),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map(
|
||||
async (item) =>
|
||||
await 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.detail_con').html();
|
||||
item.pubDate = new Date(content('p.detail_time').text() + ' GMT+8').toUTCString();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${$('ul.allnews_list_ul li.active').text()} - 剑网3`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user