Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
Soontao committed Jul 14, 2024
1 parent 1f4addd commit 096a381
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/utils/common-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,22 @@ function domAElementLinkExtractor(selector, prefix = "") {
* @returns {Partial<RSSHubArticle>}
*/
async function jsContentExtractor(page) {
const moment = require("moment");
const { extractFromHtml } = await import("@extractus/article-extractor");
const extractedData = await extractFromHtml(page.html().trim());

if (extractedData === null) {
return;
}

const parsedPublishedAt = moment(extractedData.published);

return {
title: extractedData.title,
author: extractedData.author,
link: extractedData.url,
description: extractedData.content,
pubDate: extractedData.published?.length > 0 ? new Date(parseInt(extractedData.published + "000")) : new Date(),
pubDate: parsedPublishedAt.isValid() ? parsedPublishedAt.toDate() : new Date(),
};
}

Expand Down

0 comments on commit 096a381

Please sign in to comment.