fix: update scrape function to handle HTML response and improve status messages
Some checks failed
CI/CD Pipeline / test (push) Successful in 1m34s
CI/CD Pipeline / build-image (push) Failing after 1m53s

This commit is contained in:
2025-11-30 10:51:16 +01:00
parent 02e3e77f78
commit f8a5b1b5ef

View File

@@ -41,12 +41,16 @@ function scrape(event) {
event.preventDefault(); // Prevent the default form submission event.preventDefault(); // Prevent the default form submission
updateScrapeInfo("Scraping in progress...", "blue"); updateScrapeInfo("Scraping in progress...", "blue");
fetch("/scrape") fetch("/scrape")
.then((response) => response.json()) // expect HTML response containing "Scraping completed successfully!"
.then((response) => response.text())
.then((data) => { .then((data) => {
if (data.status) { if (data.includes("Scraping completed successfully!")) {
updateScrapeInfo(data.status, "green"); updateScrapeInfo("Scraping completed successfully!", "green");
} else { } else {
updateScrapeInfo("Scraping failed. Please try again.", "red"); updateScrapeInfo(
"Scraping failed or timed out. Please try again.",
"red"
);
} }
}) })
.catch((error) => console.error("Error:", error)); .catch((error) => console.error("Error:", error));