Skip to content

Instantly share code, notes, and snippets.

@aatifbandey
Created December 6, 2020 19:44
Show Gist options
  • Save aatifbandey/7541fc5f313bd5c532f13268a691a4ee to your computer and use it in GitHub Desktop.
Save aatifbandey/7541fc5f313bd5c532f13268a691a4ee to your computer and use it in GitHub Desktop.
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