fix(route): Sky Sports pubDate (#11668)

This commit is contained in:
Ethan Shen 2023-01-23 01:27:55 +08:00 committed by GitHub
parent 0d21758052
commit 4c4b98eda5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 31 additions and 10 deletions

View File

@ -692,7 +692,7 @@ Compared to the official one, this feed:
### 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']" />\
<RouteEn author="nczitzk" example="/skysports/news/ac-milan" path="/skysports/news/:team" :paramsDesc="['Team id, can be found in URL to the team page']" />
## Soomal

View File

@ -3957,7 +3957,7 @@ router.get('/partnershiponai/resources', lazyloadRouteHandler('./routes/partners
router.get('/commonapp/blog', lazyloadRouteHandler('./routes/commonapp/blog'));
// Sky Sports
router.get('/skysports/news/:team', lazyloadRouteHandler('./routes/skysports/news'));
// router.get('/skysports/news/:team', lazyloadRouteHandler('./routes/skysports/news'));
// Europa Press
router.get('/europapress/:category?', lazyloadRouteHandler('./routes/europapress'));

View File

@ -0,0 +1,3 @@
module.exports = {
'/news/:team': ['nczitzk'],
};

View File

@ -7,6 +7,7 @@ module.exports = async (ctx) => {
const rootUrl = 'https://www.skysports.com';
const currentUrl = `${rootUrl}/${team}-news`;
const response = await got({
method: 'get',
url: currentUrl,
@ -14,19 +15,19 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('.news-list__headline-link')
.map((_, item) => {
let items = $('.news-list__headline-link')
.toArray()
.map((item) => {
item = $(item);
return {
title: item.text(),
link: item.attr('href'),
};
})
.get();
});
const items = await Promise.all(
list.map((item) =>
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
@ -35,10 +36,11 @@ module.exports = async (ctx) => {
const content = cheerio.load(detailResponse.data);
content('.roadblock').remove();
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]);
item.description = content('.sdc-article-body, .polaris-tile-group-separator').html();
item.pubDate = parseDate(detailResponse.data.match(/"datePublished": ?"(.*)","dateModified"/)[1]);
return item;
})

13
lib/v2/skysports/radar.js Normal file
View File

@ -0,0 +1,13 @@
module.exports = {
'skysports.com': {
_name: 'Sky Sports',
'.': [
{
title: 'News',
docs: 'https://docs.rsshub.app/new-media.html#sky-sports-news',
source: ['/'],
target: (params, url) => `/skysports/news/${new URL(url).toString().match(/\/(.*)-news$/)[1]}`,
},
],
},
};

View File

@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/news/:team', require('./news'));
};