launchPlaywright
Callable
Parameters
optionallaunchContext: PlaywrightLaunchContext
Optional settings passed to
browserType.launch()
. In addition to Playwright's options the object may contain our own PlaywrightLaunchContext that enable additional features.optionalconfig: Configuration = ...
Returns Promise<Browser>
Promise that resolves to Playwright's
Browser
instance.
Launches headless browsers using Playwright pre-configured to work within the Apify platform. The function has the same return value as
browserType.launch()
. See Playwright documentation for more details.The
launchPlaywright()
function alters the following Playwright options:CRAWLEE_HEADLESS
environment variable to theheadless
option, unless it was already defined by the caller orCRAWLEE_XVFB
environment variable is set to1
. Note that Apify Actor cloud platform automatically setsCRAWLEE_HEADLESS=1
to all running actors.proxyUrl
option, validates it and adds it tolaunchOptions
in a proper format. The proxy URL must define a port number and have one of the following schemes:http://
,https://
,socks4://
orsocks5://
. If the proxy is HTTP (i.e. has thehttp://
scheme) and contains username or password, thelaunchPlaywright
functions sets up an anonymous proxy HTTP to make the proxy work with headless Chrome. For more information, read the blog post about proxy-chain library.To use this function, you need to have the Playwright NPM package installed in your project. When running on the Apify Platform, you can achieve that simply by using the
apify/actor-node-playwright-*
base Docker image for your actor - see Apify Actor documentation for details.