mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-02 01:58:11 +08:00
* Initial commit of route Penguin Random House * WIP: parse books into templates * Updated radar info * Added articles route * Renamed the route and added docs * Update lib/v2/penguin-random-house/articles.js according to suggestion Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Changed category to Reading, added En docs * Changed pubDate format * Update lib/v2/penguin-random-house/router.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/penguin-random-house/articles.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/penguin-random-house/thereaddown.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Parse time * Fallback on failed regex matches * Fallback date to undefined * Update lib/v2/penguin-random-house/utils.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * fix: radar domain
50 lines
1.3 KiB
JavaScript
50 lines
1.3 KiB
JavaScript
const got = require('@/utils/got');
|
|
const cheerio = require('cheerio');
|
|
const { parseDate } = require('@/utils/parse-date');
|
|
|
|
module.exports = async (ctx) => {
|
|
const rootUrl = 'https://diskanalyzer.com';
|
|
const currentUrl = `${rootUrl}/whats-new`;
|
|
|
|
const response = await got({
|
|
method: 'get',
|
|
url: currentUrl,
|
|
});
|
|
|
|
const $ = cheerio.load(response.data);
|
|
|
|
const items = $('.blog-content h4')
|
|
.toArray()
|
|
.map((item) => {
|
|
item = $(item);
|
|
|
|
const title = item.text();
|
|
|
|
let description = '';
|
|
item.nextUntil('h4').each(function () {
|
|
description += $(this).html();
|
|
});
|
|
if (description === '') {
|
|
item.parent()
|
|
.nextUntil('h4')
|
|
.each(function () {
|
|
description += $(this).html();
|
|
});
|
|
}
|
|
|
|
return {
|
|
title,
|
|
link: currentUrl,
|
|
description,
|
|
pubDate: parseDate(title.match(/\((.*)\)/)[1], ['D MMMM YYYY', 'D MMM YYYY']),
|
|
guid: title,
|
|
};
|
|
});
|
|
|
|
ctx.state.data = {
|
|
title: $('title').text(),
|
|
link: currentUrl,
|
|
item: items,
|
|
};
|
|
};
|