-
-
Save AnderRV/6a8a3f7fd61a44f2a7ff5f4b32f28aa9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const playwright = require('playwright'); | |
const axios = require('axios'); | |
const cheerio = require('cheerio'); | |
const getHtmlPlaywright = async url => { | |
const browser = await playwright.chromium.launch(); | |
const context = await browser.newContext(); | |
const page = await context.newPage(); | |
await page.goto(url); | |
const html = await page.content(); | |
await browser.close(); | |
return html; | |
}; | |
const getHtmlAxios = async url => { | |
const { data } = await axios.get(url); | |
return data; | |
}; | |
(async () => { | |
const html = await getHtmlPlaywright('https://scrapeme.live/shop/page/1/'); | |
const $ = cheerio.load(html); | |
const content = extractContent($); | |
console.log('getHtmlPlaywright', content); | |
})(); | |
(async () => { | |
const html = await getHtmlAxios('https://scrapeme.live/shop/page/1/'); | |
const $ = cheerio.load(html); | |
const content = extractContent($); | |
console.log('getHtmlAxios', content); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment