Last active
March 10, 2019 01:13
-
-
Save bouiboui/f489ce4b328cd11afc0b749973aa21f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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