Last active
November 8, 2020 10:46
-
-
Save berkslv/3fddc1e1972b7f1c31b30802c359d166 to your computer and use it in GitHub Desktop.
puppeter using
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
async function scrapePrice(url){ | |
const browser = await puppeteer.launch(); | |
const page = await browser.newPage(); | |
await page.goto(url); | |
const [el] = await page.$x('<XPath>'); | |
const txt = await (await el.getProperty('textContent')).jsonValue(); // return 9,71 but parseFloat need to period not comma | |
browser.close(); | |
let stringTxt = JSON.stringify(txt).replace('"',"").replace('"',"").replace(",","."); // first change json to string type, this return "number.decimal" and some string methods | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment