Skip to content

Instantly share code, notes, and snippets.

@fedetibaldo
Last active March 21, 2018 07:49
Show Gist options
  • Save fedetibaldo/25b96c393225db65db537bbbe07969c6 to your computer and use it in GitHub Desktop.
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
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