I have cors-anywhere server running together with my ReactJS project which I'm using to scrape some info from various pages. For one specific URL the system returns an error
https://www.fibank.bg/en/currency-rates
<b>Error when loading the page.</b><br /><br />
The reason for this error could be add-on or extension in your browser.<br /><br />
Please, check the active add-ons and extensions in your browser or try to open the webpage from another browser.<br /><br />
If this error appears again, you can send us its ID (<b id="ide"> ... </b>) by email to <a href="mailto:[email protected]">[email protected]</a>. We will provide you further instructions.<br /><br />
Regards,<br />
Fibank team<br /><br />
You can reproduce the same error I'm getting on the cors-anywhere demo page https://robwu.nl/cors-anywhere.html Below is the code I'm using in my project.
useEffect(() => {
fetch(
`http://localhost:8080/https://thehiddenurl`,
)},
{
headers: {
"Content-Type": "application/json",
},
}
)
.then((response) => response.text())
.then((result) => {
if (result) {
const el = document.createElement("html");
el.innerHTML = result;
const arr = Array.from(el.getElementsByTagName("tr"));
const filtered = arr.filter((el) => {
return CURRENCIES.includes(getCurrencyStr(el));
});
filtered.forEach((el) => {
const currentCurrency = getCurrencyStr(el);
if (currentCurrency && currentCurrency in DEFAULT_CURRENCY) {
DEFAULT_CURRENCY[currentCurrency].buy = el.children[4].innerHTML;
DEFAULT_CURRENCY[currentCurrency].sell = el.children[5].innerHTML;
}
});
setCurrencyRates(DEFAULT_CURRENCY);
} else {
throw new Error(result.message);
}
})
.catch((error) => console.log(error.message));
}, []);