This file contains hidden or 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
| /*Immediately Executing Function: | |
| You can execute a function immediately after you define it. | |
| Simply wrap the function in parentheses () and invoke it | |
| The reason for having an IEF is to create a new variable scope. | |
| Example: | |
| -------- | |
| */ | |
| (function test() { console.log('test was executed!'); })(); |
This file contains hidden or 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 puppeteer = require('puppeteer'); | |
| (async () => { | |
| try { | |
| const browser = await puppeteer.launch({ | |
| headless: false, | |
| }) | |
| const page = await browser.newPage(); | |
| await page.setBypassCSP(true); | |
| await page.goto('https://github.com/google'); | |
| await page.addScriptTag({ |
This file contains hidden or 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 fse = require('fs-extra'); | |
| const puppeteer = require('puppeteer'); | |
| const getPdf = (page) => { | |
| let url = await page.url(); | |
| return page.evaluate(url => { | |
| return new Promise(async resolve => { | |
| const reader = new FileReader(); | |
| const response = await window.fetch(url, { | |
| credentials: 'same-origin', | |
| method: 'POST' |
OlderNewer