Answers for "node.js web scraping"

0

web scraping nodejs

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()
})()
Posted by: Guest on December-27-2020
0

node.js web scraping

//eventhough deprecated, still able to use
const request = require('request');
request('http://www.google.com', function (error, response, body) {
  console.error('error:', error); // Print the error if one occurred
  console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
  console.log('body:', body); // Print the HTML for the Google homepage.
});
Posted by: Guest on April-01-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language