updated the function, uses node-fetch now

pull/73/head
Maria-Aidarus 2023-11-24 20:59:37 +03:00
rodzic 96a2bfb87c
commit e34158bcb5
1 zmienionych plików z 5 dodań i 15 usunięć

Wyświetl plik

@ -6,21 +6,11 @@ import { fetch } from 'node-fetch';
// Placeholder function to fetch content from URL using a web scraping service
async function fetchContentFromURL(url) {
return new Promise((resolve, reject) => {
https.get(url, (response) => {
let data = '';
// A chunk of data has been received.
response.on('data', (chunk) => {
data += chunk;
});
// The whole response has been received.
response.on('end', () => {
resolve(data);
});
}).on("error", (error) => {
reject(`Error fetching URL: ${error.message}`);
});
});
const response = await fetch(url);
if (!response.ok) {
throw new Error(`Error fetching URL: ${response.statusText}`);
}
return await response.text();
}
function simplifyContent(content) {