mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
@@ -194,6 +194,20 @@ pageClass: routes
|
||||
|
||||
<Route author="xyqfer" example="/itjuzi/merge" path="/itjuzi/merge"/>
|
||||
|
||||
## Kotaku
|
||||
|
||||
### Story
|
||||
|
||||
<Route author="CYTMWIA" example="/kotaku/story/news" path="/kotaku/story/:type" :paramsDesc="['Story类型']">
|
||||
|
||||
可在 url 中找到,例如`https://kotaku.com/c/news`和`https://kotaku.com/c/kotaku-east`中的`news`和`kotaku-east`
|
||||
|
||||
注意,无论是`news`还是`kotaku-east`之前都有`/c/`
|
||||
|
||||
所以,如果您把`https://kotaku.com/latest`中的`latest`填入,该路由并不会正常工作
|
||||
|
||||
</Route>
|
||||
|
||||
## Krankenkassen 德国新闻社卫健新闻
|
||||
|
||||
### dpa news
|
||||
|
||||
@@ -3062,6 +3062,9 @@ router.get('/telecompaper/news/:caty/:year?/:country?/:type?/:keyword?', require
|
||||
// 水木社区
|
||||
router.get('/newsmth/account/:id', require('./routes/newsmth/account'));
|
||||
|
||||
// Kotaku
|
||||
router.get('/kotaku/story/:type', require('./routes/kotaku/story'));
|
||||
|
||||
// 梅斯医学
|
||||
router.get('/medsci/recommend', require('./routes/medsci/recommend'));
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const storyUrl = `https://kotaku.com/c/${ctx.params.type}`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: storyUrl,
|
||||
});
|
||||
|
||||
const data = response.data;
|
||||
|
||||
const $ = cheerio.load(data);
|
||||
const list = $('article');
|
||||
|
||||
const itemList = list
|
||||
.map((index, item) => {
|
||||
item = $(item);
|
||||
const titleElem = item.find('h2').first();
|
||||
const dateTime = item.find('time').first().attr('datetime');
|
||||
return {
|
||||
title: titleElem.length === 0 ? 'Untitled' : titleElem.text(),
|
||||
author: item.find('a[href*="/author/"]').last().text(),
|
||||
description: item.find('p').first().text(),
|
||||
link: titleElem.parent().attr('href'),
|
||||
pubDate: new Date(dateTime).toUTCString(),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: storyUrl,
|
||||
language: 'en-US',
|
||||
item: itemList,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user