mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-19 06:38:55 +08:00
feat(route): add yuzu emulator blog (#7947)
Co-authored-by: NeverBehave <gayhub@never.pet>
This commit is contained in:
@@ -90,6 +90,12 @@ pageClass: routes
|
||||
|
||||
<Route author="Lonor" example="/blogs/wordpress/lawrence.code.blog" path="/blogs/wordpress/:domain/:https?" :paramsDesc="['WordPress 博客域名', '默认 https 协议。填写 `http`或`https`']"/>
|
||||
|
||||
## yuzu emulator
|
||||
|
||||
### Entry
|
||||
|
||||
<Route author="nczitzk" example="/yuzu-emu/entry" path="/yuzu-emu/entry" />
|
||||
|
||||
## 阿里云系统组技术博客
|
||||
|
||||
### 首页
|
||||
|
||||
@@ -42,3 +42,8 @@ pageClass: routes
|
||||
|
||||
<Route author="Lonor" example="/blogs/wordpress/lawrence.code.blog" path="/blogs/wordpress/:domain/:https?" :paramsDesc="['WordPress blog domain', 'use https by default. options: `http` or `https`']"/>
|
||||
|
||||
## yuzu emulator
|
||||
|
||||
### Entry
|
||||
|
||||
<RouteEn author="nczitzk" example="/yuzu-emu/entry" path="/yuzu-emu/entry" />
|
||||
@@ -4169,6 +4169,9 @@ router.get('/tanchinese/:category?', require('./routes/tanchinese'));
|
||||
// Harvard
|
||||
router.get('/harvard/health/blog', require('./routes/universities/harvard/health/blog'));
|
||||
|
||||
// yuzu emulator
|
||||
router.get('/yuzu-emu/entry', require('./routes/yuzu-emu/entry'));
|
||||
|
||||
// 温州大学
|
||||
router.get('/wzu/news', require('./routes/universities/wzu/news'));
|
||||
|
||||
|
||||
53
lib/routes/yuzu-emu/entry.js
Normal file
53
lib/routes/yuzu-emu/entry.js
Normal file
@@ -0,0 +1,53 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'https://yuzu-emu.org';
|
||||
const currentUrl = `${rootUrl}/entry`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('.blog-entry-header')
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
|
||||
return {
|
||||
link: item.attr('data-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);
|
||||
|
||||
const meta = content('.h3').text().trim().split(' on ');
|
||||
|
||||
item.title = content('.title').text();
|
||||
item.description = content('.content').html();
|
||||
item.author = meta[0].replace('Written by ', '');
|
||||
item.pubDate = parseDate(meta[1], 'MMMM DD YYYY');
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user