Apify Discord Mirror

Updated 4 months ago

How to use Playwright's bypassCsp option?

At a glance

The community member is trying to use the bypassCSP option from the Playwright API in the Crawlee framework. One community member provided a sample code snippet to try, but the community member received a TypeScript error indicating that bypassCSP is not a known property in the LaunchOptions type. Another community member confirmed that the code works when using the latest version of Playwright, and the original community member was able to resolve the issue by updating the Playwright version.

Useful resources
I would like to use:

https://playwright.dev/docs/api/class-testoptions#test-options-bypass-csp

Any idea how I can do that in crawlee?
J
L
5 comments
Hi @Jeno
You can try:

const playwrightCrawler = new PlaywrightCrawler({ launchContext: { launchOptions: { bypassCSP: true }, }, });
Hi @Lukas Celnar ,

I get this ts error:

Object literal may only specify known properties, and 'bypassCSP' does not exist in type 'LaunchOptions'. ts(2353)
Hi @Jeno
Could you please confirm that you are using playwright with latest version of crawlee?

I was able to successfully run this exact code without any error and typescript error/warning:
const crawler = new PlaywrightCrawler({ proxyConfiguration, requestHandler: router, headless: false, launchContext: { launchOptions: { bypassCSP: true }, }, });
Indeed, I just updated Playwright version and it accepts the option. Thank you for your help!
Add a reply
Sign up and join the conversation on Discord