Playwright Integration

Playwright is Microsoft's modern browser automation library supporting Chromium, Firefox, and WebKit. Connect it to Scrapfly Cloud Browser for scalable automation with built-in proxies and fingerprinting.

Beta Feature: Cloud Browser is currently in beta.

Installation & Quick Start

Install Playwright and connect to Cloud Browser:

Installation
Quick Start Example
Installation
Quick Start Example

Connection Parameters

Configure your Cloud Browser connection with these WebSocket URL parameters:

Parameter Required Description
api_key Required Your Scrapfly API key
proxy_pool Optional datacenter (default) or residential
os Optional OS fingerprint: linux, windows, macos
session Optional Session ID for persistent browser state
country Optional Proxy country code (ISO 3166-1 alpha-2)

Data Extraction

Extract data from a dynamic page:

Form Interaction

Fill forms and handle login flows:

Session Persistence

Maintain browser state across connections using the session parameter:

Proxy Options

Proxy Pool Use Case Cost
datacenter General scraping, high speed, lower cost 1 credits/30s + 2 credits/MB
residential Protected sites, geo-targeting, anti-bot bypass 1 credits/30s + 10 credits/MB

Error Handling

Always handle errors and ensure proper browser cleanup to prevent billing leaks:

Important: Failing to close the browser will keep the session running and continue billing. Always use try/finally blocks.

Best Practices

  • Use connectOverCDP - Playwright's CDP connection method for remote browsers
  • Handle disconnects - Wrap connections in try/catch
  • Close browsers - Always call browser.close() to stop billing
  • Use sessions wisely - Reuse sessions for multi-step flows
  • Leverage Playwright features - Use locators, auto-waiting, and built-in assertions

Summary