const matchedLinks = [];
const pagesQuantity = 10;
const textToLookup = 'ясос биба';
const websiteLink = 'sait.da/users/';
function parseLink(pageNumber) {
const xhr = new XMLHttpRequest();
xhr.open('GET', `https://cors-anywhere.herokuapp.com/${websiteLink}${pageNumber}`);
xhr.send();
xhr.onload = function () {
if (xhr.status != 200) {
console.log(`Ошибка ${xhr.status}: ${xhr.statusText}`);
} else {
if (xhr.response.indexOf(textToLookup) !== -1) {
matchedLinks.push(`${websiteLink}${pageNumber}`);
}
}
};
}
for (let i = 1; i < pagesQuantity; i++) {
parseLink(i);
}