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
updateScrapeInfo("Scraping in progress...", "blue");
fetch("/scrape")
.then((response) => response.json())
// expect HTML response containing "Scraping completed successfully!"
.then((response) => response.text())
.then((data) => {
if (data.status) {
updateScrapeInfo(data.status, "green");
if (data.includes("Scraping completed successfully!")) {
updateScrapeInfo("Scraping completed successfully!", "green");
} else {
updateScrapeInfo("Scraping failed. Please try again.", "red");
updateScrapeInfo(
"Scraping failed or timed out. Please try again.",
"red"
);
}
})
.catch((error) => console.error("Error:", error));