web scraping puppetter tutorial code example

Example: web scraping node js puppeteer

const puppeteer = require('puppeteer')
const $ = require('cheerio')

(async () => {
	const browser = await puppeteer.launch()
	const page = await browser.newPage()
	await page.goto('https://www.imdb.com/title/tt7126948/?ref_=nv_sr_srsg_0', { waitUntil: 'networkidle0' })

	const content = await page.evaluate(() => document.body.innerHTML)
	const data = $('div[class="title_wrapper"]', content).find('h1').text()

	console.log(data)

	await browser.close()
})()