Created
April 30, 2019 17:34
-
-
Save jslnriot/31d7bf0a721655be349079b5744789db 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
import axios from 'axios'; | |
import cherrio from 'cheerio'; | |
async function getHTML(productURL) { | |
const { data: html } = await axios.get(productURL, { | |
headers: { | |
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36' | |
} | |
}) | |
.catch(function (error) { | |
console.log(error); | |
}) | |
return html; | |
} | |
async function getAmazonPrice(html) { | |
const $ = cherrio.load(html) | |
const span = $('#priceblock_ourprice') | |
return span.html(); | |
} | |
export { getHTML, getAmazonPrice }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment