mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat: Add some error handling for when certain pieces of HTML a… (#3594)
This commit is contained in:
@@ -6,14 +6,18 @@ async function load(link) {
|
||||
const response = await got.get(link);
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const shotMedia = $('.media-shot').html();
|
||||
const shotDescription = $('.shot-desc').html();
|
||||
const shotMedia = $('.media-shot').html() || $('.main-shot').html() || '';
|
||||
const shotDescription = $('.shot-desc').html() || '';
|
||||
|
||||
const shotViews = $('.shot-views').text() || '0 views';
|
||||
const shotLikes = $('.shot-likes').text() || '0 likes';
|
||||
const shotSaves = $('.shot-saves').text() || '0 saves';
|
||||
|
||||
const description = `${shotMedia}<br />
|
||||
${shotDescription}<br />
|
||||
${$('.shot-views').text()}<br />
|
||||
${$('.shot-likes').text()}<br />
|
||||
${$('.shot-saves').text()}`;
|
||||
${shotViews}<br />
|
||||
${shotLikes}<br />
|
||||
${shotSaves}`;
|
||||
|
||||
const pubDateString = $('.shot-date').text();
|
||||
const pubDate = new Date(pubDateString).toUTCString();
|
||||
|
||||
Reference in New Issue
Block a user