Skip to content

Instantly share code, notes, and snippets.

Last active Sep 25, 2019
What would you like to do?
const axios = require('axios').default;
const JSDOM = require('jsdom').JSDOM;
module.exports.price = async event => {
var encoded_url = encodeURI("");
const res = await axios.get(encoded_url);
const document = new JSDOM(;
const title_with_whitespace = document.querySelector("#productTitle").textContent;
const title = title_with_whitespace.replace(/(?:\r\n|\r|\n)/g, '').trim();
const price_with_ending = document.querySelector("#priceblock_ourprice").textContent;
const price = price_with_ending.substring(0, price_with_ending.length - 2).replace(',', '.');
return {
statusCode: res.status,
body: JSON.stringify({
title: title,
price: price
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment