mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat(route): add x410 news (#7339)
Co-authored-by: NeverBehave <gayhub@never.pet>
This commit is contained in:
co-authored by
NeverBehave
parent
ae51da7cae
commit
f5ff75c543
@@ -339,6 +339,12 @@ Refer to [#minecraft](/en/game.html#minecraft)
|
||||
|
||||
<RouteEn author="cnzgray" example="/typora/changelog" path="/typora/changelog"/>
|
||||
|
||||
## X410
|
||||
|
||||
### News
|
||||
|
||||
<RouteEn author="nczitzk" example="/x410/news" path="/x410/news"/>
|
||||
|
||||
## Xiaomi.eu
|
||||
|
||||
### ROM Releases
|
||||
|
||||
@@ -432,6 +432,12 @@ pageClass: routes
|
||||
|
||||
<Route author="nczitzk" example="/typora/changelog-dev/macOS" path="/typora/changelog-dev/:os" :paramsDesc="['操作系统类型, 可选 `macOS` 或 `Windows` 与 `Linux`,默认为 `macOS`']"/>
|
||||
|
||||
## X410
|
||||
|
||||
### News
|
||||
|
||||
<Route author="nczitzk" example="/x410/news" path="/x410/news"/>
|
||||
|
||||
## xclient.info
|
||||
|
||||
### 应用更新
|
||||
|
||||
@@ -4158,6 +4158,8 @@ router.get('/tanchinese/:category?', require('./routes/tanchinese'));
|
||||
// Harvard
|
||||
router.get('/harvard/health/blog', require('./routes/universities/harvard/health/blog'));
|
||||
|
||||
// X410
|
||||
router.get('/x410/news', require('./routes/x410/news'));
|
||||
// 恩山无线论坛
|
||||
router.get('/right/forum/:id?', require('./routes/right/forum'));
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'https://x410.dev';
|
||||
const currentUrl = `${rootUrl}/news`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('.entry-title a')
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.text(),
|
||||
link: 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('.fusion-content-tb').html();
|
||||
item.pubDate = Date.parse(content('meta[property="article:published_time"]').attr('content'));
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user