kopia lustrzana https://github.com/learn-awesome/learndb
trying node-fetch now
rodzic
e34158bcb5
commit
5dc0645826
|
@ -6,11 +6,21 @@ import { fetch } from 'node-fetch';
|
||||||
|
|
||||||
// Placeholder function to fetch content from URL using a web scraping service
|
// Placeholder function to fetch content from URL using a web scraping service
|
||||||
async function fetchContentFromURL(url) {
|
async function fetchContentFromURL(url) {
|
||||||
const response = await fetch(url);
|
return new Promise((resolve, reject) => {
|
||||||
if (!response.ok) {
|
https.get(url, (response) => {
|
||||||
throw new Error(`Error fetching URL: ${response.statusText}`);
|
let data = '';
|
||||||
}
|
// A chunk of data has been received.
|
||||||
return await response.text();
|
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}`);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function simplifyContent(content) {
|
function simplifyContent(content) {
|
||||||
|
|
Ładowanie…
Reference in New Issue