Skip to content

Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.

Fix #566

Ondra Urban31dd49ce6609
diff --git a/src/puppeteer.js b/src/puppeteer.js
index 0d4239f61..c8d1d972a 100644
--- a/src/puppeteer.js
+++ b/src/puppeteer.js
@@ -17,6 +17,11 @@ const LAUNCH_PUPPETEER_DEFAULT_VIEWPORT = {
height: 768,
};
+const LAUNCH_PUPPETEER_APIFY_OPTIONS = [
+ 'proxyUrl', 'userAgent', 'useChrome', 'useApifyProxy', 'apifyProxyGroups',
+ 'apifyProxySession', 'puppeteerModule', 'stealth', 'stealthOptions',
+];
+
/**
* Apify extends the launch options of Puppeteer.
* You can use any of the
@@ -104,7 +109,8 @@ const launchPuppeteerWithProxy = async (puppeteer, opts) => {
optsForLog.args = opts.args.slice(0, opts.args.length - 1);
log.info('Launching Puppeteer', optsForLog);
- const browser = await puppeteer.launch(opts);
+ const onlyPuppeteerOptions = _.omit(opts, LAUNCH_PUPPETEER_APIFY_OPTIONS);
+ const browser = await puppeteer.launch(onlyPuppeteerOptions);
// Close anonymization proxy server when Puppeteer finishes
if (anonymizedProxyUrl) {
@@ -266,7 +272,8 @@ export const launchPuppeteer = async (options = {}) => {
browser = await launchPuppeteerWithProxy(puppeteer, optsCopy);
} else {
log.info('Launching Puppeteer', _.omit(optsCopy, LAUNCH_PUPPETEER_LOG_OMIT_OPTS));
- browser = await puppeteer.launch(optsCopy);
+ const onlyPuppeteerOptions = _.omit(optsCopy, LAUNCH_PUPPETEER_APIFY_OPTIONS);
+ browser = await puppeteer.launch(onlyPuppeteerOptions);
}
// Add stealth