We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@dagumak couldn't you catch the responses and write the files to a location of your choice?
const puppeteer = require('puppeteer'); const fs = require('fs'); const mime = require('mime'); const URL = require('url').URL; (async() => { const browser = await puppeteer.launch(); const page = await browser.newPage(); const responses = []; page.on('response', resp => { responses.push(resp); }); page.on('load', () => { responses.map(async (resp, i) => { const request = await resp.request(); const url = new URL(request.url()); const split = url.pathname.split('/'); let filename = split[split.length - 1]; if (!filename.includes('.')) { filename += '.html'; } const buffer = await resp.buffer(); fs.writeFileSync(filename, buffer); }); }); await page.goto('https://news.ycombinator.com/', {waitUntil: 'networkidle'}); browser.close(); })();
You may need to adjust the timing for your page. Waiting for the load event and networkidle might not be enough.
load
networkidle
Originally posted by @ebidel in #299 (comment)
The text was updated successfully, but these errors were encountered:
The const url = new URL(request.url); should be const url = new URL(request.url()); if I am not mistaken.
const url = new URL(request.url);
const url = new URL(request.url());
Sorry, something went wrong.
No branches or pull requests
@dagumak couldn't you catch the responses and write the files to a location of your choice?
You may need to adjust the timing for your page. Waiting for the
load
event andnetworkidle
might not be enough.Originally posted by @ebidel in #299 (comment)
The text was updated successfully, but these errors were encountered: