I'm trying to scrape prices of amazon search results using jQuery, but I keep getting this error "Uncaught TypeError: results[i].find is not a function".
scrape.js
/// example: user searched 'keyboards' on amazon
//grab search result rows from amazon search result page
var results = $('.s-main-slot.s-result-list.s-search-results.sg-row').children;
console.log(results) //htmlCollection(30)[divRow1, divRow2,...,divRow30]
//loop through table results and find child element for price
for (var i=0; i<results.length; i++){
let r = results[i].find('a-price'); //<--- error
console.log(r);
};
I've also tried:
//grab search result rows from amazon search result page
var results = $('.s-main-slot.s-result-list.s-search-results.sg-row').children;
console.log(results) //htmlCollection(30)[divRow1, divRow2,...,divRow30]
//loop through table results and find child element for price
for (var i=0; i<results.length; i++){
let r = $(results[i]).find('a-price'); //<--- error
console.log(r);
};
and this.
//grab search result rows from amazon search result page
var results = $('.s-main-slot.s-result-list.s-search-results.sg-row').children;
console.log(results) //htmlCollection(30)[divRow1, divRow2,...,divRow30]
//loop through table results and find child element for price
for (var i=0; i<results.length; i++){
let r = $(this).find('a-price'); //<--- error
console.log(r);
};
Same error: .find is not a function. I think the bug is that i'm referencing a DOM object and not a jQuery object, but I can't seem to figure out how to fix that.