i created a while loop that will keep scraping a page for a certain movie until it is found, this is an external module/helper by the way, but for some reason it doesn't work, this function is later called in order to get the data result from result and then grab the item in the result array the result will also have name of the movie and price
const movies = "AVENGERS END GAME;
module.exports = {
spider: function () {
var target = 2
const extractmovies = document.querySelectorAll('some.selector1')
let result = [];
let targetss = [];
var movie_Name, movie_Price
var i = 0;
while (result <= 2) {
for ( extract of extractmovies) {
const nameChk = extract.querySelector('selector')
item_Name = nameChk.innerText
const priceChk = extract.querySelector('g.iu')
item_Price = parseInt(priceChk.getAttribute('ggfg'))
result.push({
Name: item_Name,
Price: item_Price,
})
}
for (myTarget of result) {
if (myTarget.Name == keywords) {
targetss.push(1)
}
}
i++;
}
return targetss;
}
}