Skip to content

Instantly share code, notes, and snippets.

@bouiboui
Last active March 10, 2019 01:13
Show Gist options
  • Save bouiboui/f489ce4b328cd11afc0b749973aa21f1 to your computer and use it in GitHub Desktop.
Save bouiboui/f489ce4b328cd11afc0b749973aa21f1 to your computer and use it in GitHub Desktop.
const scrapeIt = require('scrape-it');
const fetchAmazonSearchResults = async query => {
const {data} = await scrapeIt(process.env.AMAZON_SEARCH_URL + query, {
results: {
listItem: '.s-result-item',
data: {
image: {
selector: '.s-image',
attr: 'src'
},
title: {
selector: '.s-image',
attr: 'alt'
},
price: '.a-price',
link: {
selector: '.a-link-normal',
how: a => a.attr('href')
},
stars: {
selector: '.a-icon-star-small',
how: a => a.attr('class')
}
}
}
});
return data;
};
module.exports = fetchAmazonSearchResults;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment