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.

Merge branch 'develop' into feature/hiding-tricks-puppeteer

Petr Patekf8a03239e845
diff --cc src/puppeteer.js
index a37702a4f,e231044f9..589b421a3
--- a/src/puppeteer.js
+++ b/src/puppeteer.js
@@@ -4,10 -4,8 +4,9 @@@ import { anonymizeProxy, closeAnonymize
import log from 'apify-shared/log';
import { ENV_VARS } from 'apify-shared/consts';
import { DEFAULT_USER_AGENT } from './constants';
- import { newPromise, getTypicalChromeExecutablePath, isAtHome } from './utils';
+ import { getTypicalChromeExecutablePath, isAtHome } from './utils';
import { getApifyProxyUrl } from './actor';
- import { registerBrowserForLiveView } from './puppeteer_live_view_server';
+import Stealth from './stealth/stealth';
/* global process, require */
@@@ -205,23 -188,15 +189,26 @@@ export const launchPuppeteer = async (o
checkParamOrThrow(options.args, 'options.args', 'Maybe [String]');
checkParamOrThrow(options.proxyUrl, 'options.proxyUrl', 'Maybe String');
checkParamOrThrow(options.useApifyProxy, 'options.useApifyProxy', 'Maybe Boolean');
- checkParamOrThrow(options.liveView, 'options.liveView', 'Maybe Boolean');
- checkParamOrThrow(options.liveViewOptions, 'options.liveViewOptions', 'Maybe Object');
+ checkParamOrThrow(options.puppeteerModule, 'options.puppeteerModule', 'Maybe String');
if (options.useApifyProxy && options.proxyUrl) throw new Error('Cannot combine "options.useApifyProxy" with "options.proxyUrl"!');
+ if (options.liveView || options.liveViewOptions) {
+ log.deprecated('Live view is no longer available in Apify.launchPuppeteer() and launchPuppeteerOptions. '
+ + 'Use options.useLiveView in PuppeteerPool for an updated version. '
+ + 'For live view with Apify.launchPuppeteer(), use Apify.LiveViewServer.');
+ }
- const puppeteer = getPuppeteerOrThrow();
-
+ const puppeteer = getPuppeteerOrThrow(options.puppeteerModule);
+ // Add stealth
+ if (options.stealth) {
+ const prevLaunch = puppeteer.launch;
+ const newLaunch = async function (...args) {
+ const browser = await prevLaunch.bind(puppeteer)(...args);
+ const stealth = new Stealth(options.stealth);
+ return stealth.getStealthBrowser(browser);
+ };
+
+ puppeteer.launch = newLaunch.bind(puppeteer);
+ }
const optsCopy = Object.assign({}, options);
optsCopy.args = optsCopy.args || [];