Skip to content

Instantly share code, notes, and snippets.

@SavvasStephanides
Created May 19, 2022 10:33
Show Gist options
  • Save SavvasStephanides/66532e27a5014aaecd4fedd92356265c to your computer and use it in GitHub Desktop.
Save SavvasStephanides/66532e27a5014aaecd4fedd92356265c to your computer and use it in GitHub Desktop.
const axios = require("axios")
const jsdom = require("jsdom")
const { JSDOM } = jsdom
async function run(){
const url = "https://savvas.me/explained/promises"
let response = await axios.get(url)
let html = response.data
const page = new JSDOM(html)
let title = page.window.document.querySelector("meta[property='og:title']").getAttribute("content")
let thumbnail = page.window.document.querySelector("meta[property='og:image']").getAttribute("content")
console.log(title)
console.log(thumbnail)
}
run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment