4.6.7 first pr (#726)

This commit is contained in:
Archer
2024-01-10 23:35:04 +08:00
committed by GitHub
parent 414b693303
commit 006ad17c6a
186 changed files with 2996 additions and 1838 deletions

View File

@@ -50,8 +50,11 @@ export const cheerioToHtml = ({
.get()
.join('\n');
const title = $('head title').text() || $('h1:first').text() || fetchUrl;
return {
html,
title,
usedSelector
};
};
@@ -70,7 +73,7 @@ export const urlsFetch = async ({
});
const $ = cheerio.load(fetchRes.data);
const { html, usedSelector } = cheerioToHtml({
const { title, html, usedSelector } = cheerioToHtml({
fetchUrl: url,
$,
selector
@@ -79,6 +82,7 @@ export const urlsFetch = async ({
return {
url,
title,
content: md,
selector: usedSelector
};
@@ -87,6 +91,7 @@ export const urlsFetch = async ({
return {
url,
title: '',
content: '',
selector: ''
};

View File

@@ -15,7 +15,9 @@ export const htmlToMarkdown = (html?: string | null) =>
worker.on('message', (md: string) => {
worker.terminate();
resolve(simpleMarkdownText(md));
let rawText = simpleMarkdownText(md);
resolve(rawText);
});
worker.on('error', (err) => {
worker.terminate();