Last active
March 21, 2018 07:49
-
-
Save fedetibaldo/25b96c393225db65db537bbbe07969c6 to your computer and use it in GitHub Desktop.
The minimum setup necessary to make puppeteer return the response body of a request
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 gulp = require('gulp') | |
const puppeteer = require('puppeteer') | |
const err = (err) => console.log(err) | |
gulp.task('puppeteer', async (done) => { | |
const browser = await puppeteer.launch() | |
const page = await browser.newPage() | |
await page.goto('http://localhost/puppeteer/build/') | |
.then( async (response) => { | |
await response.text() | |
.then( text => console.log(text) ) | |
.catch(err) | |
}) | |
.catch(err) | |
done() | |
}) | |
gulp.on('stop', () => { | |
process.nextTick( () => process.exit(0) ) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment