Created
December 6, 2020 19:44
-
-
Save aatifbandey/7541fc5f313bd5c532f13268a691a4ee 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
import puppeteer from 'puppeteer-core'; | |
export const executeCron = async()=> { | |
try { | |
const browser = await puppeteer.launch({ | |
// headless: false, | |
args, | |
executablePath: __DEV__ | |
? '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' | |
: '/usr/bin/google-chrome-unstable', | |
}); | |
const context = await browser.createIncognitoBrowserContext(); | |
const page = await context.newPage(); | |
await page.goto("https://www.tokopedia.com", { waitUntil: 'networkidle2' }) | |
const htmlData = await page.evaluate(() => document.querySelector('head').outerHTML); | |
await context.close(); | |
await browser.close(); | |
return htmlData; | |
} catch(err){ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment