mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-10 07:12:51 +08:00
feat(route): add Sky Sports News (#7968)
Co-authored-by: Sukka <isukkaw@gmail.com> Co-authored-by: NeverBehave <gayhub@never.pet>
This commit is contained in:
@@ -414,6 +414,12 @@ Compared to the official one, this feed:
|
||||
|
||||
</RouteEn>
|
||||
|
||||
## Sky Sports
|
||||
|
||||
### News
|
||||
|
||||
<RouteEn author="nczitzk" example="/skysports/news/ac-milan" path="/skysports/news/:team" :paramsDesc="['Team id, can be found in URL to the team page']" />\
|
||||
|
||||
## The Brain
|
||||
|
||||
### Blog
|
||||
|
||||
@@ -639,6 +639,12 @@ IPFS 网关有可能失效,那时候换成其他网关。
|
||||
|
||||
</Route>
|
||||
|
||||
## Sky Sports
|
||||
|
||||
### News
|
||||
|
||||
<Route author="nczitzk" example="/skysports/news/ac-milan" path="/skysports/news/:team" :paramsDesc="['球队 id,可在球队对应页面的 URL 中找到']" />
|
||||
|
||||
## TANC 艺术新闻
|
||||
|
||||
### 分类
|
||||
|
||||
@@ -4169,13 +4169,19 @@ router.get('/tanchinese/:category?', require('./routes/tanchinese'));
|
||||
// Harvard
|
||||
router.get('/harvard/health/blog', require('./routes/universities/harvard/health/blog'));
|
||||
|
||||
// Sky Sports
|
||||
router.get('/skysports/news/:team', require('./routes/skysports/news'));
|
||||
|
||||
// Europa Press
|
||||
router.get('/europapress/:category?', require('./routes/europapress'));
|
||||
|
||||
// World Happiness Report
|
||||
router.get('/worldhappiness/blog', require('./routes/worldhappiness/blog'));
|
||||
router.get('/worldhappiness/archive', require('./routes/worldhappiness/archive'));
|
||||
|
||||
// 中国纺织经济信息网
|
||||
router.get('/ctei/news/:id?', require('./routes/ctei/news'));
|
||||
|
||||
// 时事一点通
|
||||
router.get('/ssydt/article/:id?', require('./routes/ssydt/article'));
|
||||
|
||||
|
||||
53
lib/routes/skysports/news.js
Normal file
53
lib/routes/skysports/news.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 team = ctx.params.team;
|
||||
|
||||
const rootUrl = 'https://www.skysports.com';
|
||||
const currentUrl = `${rootUrl}/${team}-news`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('.news-list__headline-link')
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
|
||||
return {
|
||||
title: item.text(),
|
||||
link: 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);
|
||||
|
||||
content('.sdc-article-widget, .sdc-site-layout-sticky-region').remove();
|
||||
|
||||
item.description = content('.sdc-article-body').html();
|
||||
item.pubDate = parseDate(detailResponse.data.match(/"datePublished": "(.*)","dateModified"/)[1]);
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user