Skip to content

Instantly share code, notes, and snippets.

@berkslv
Last active November 8, 2020 10:46
Show Gist options
  • Save berkslv/3fddc1e1972b7f1c31b30802c359d166 to your computer and use it in GitHub Desktop.
Save berkslv/3fddc1e1972b7f1c31b30802c359d166 to your computer and use it in GitHub Desktop.
puppeter using
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