Integrating Scraping Browser with Playwright

The AutoScraper Scraping Browser is a fully managed, out-of-the-box scraping solution designed to simplify the web scraping process. It seamlessly integrates with Puppeteer and allows you to scrape websites using our powerful infrastructure and rotating residential IP pool of over 55 million IPs from 190+ countries, all while maintaining a 99.9% uptime.

This guide will show you how to integrate Scraping Browser into your Puppeteer script with just one line of code, providing a fast and easy way to enhance your scraping capabilities.


Installing the required libraries

Puppeteer-Core is a lightweight version of the Puppeteer library explicitly designed to connect to an existing browser instance instead of launching a new one.

You can install puppeteer-core by running:

npm install playwright

Quick Integration with Scraping Browser Without the SDK

If you already have a Puppeteer setup running smoothly, integrating with AutoScraper Scraping Browser is incredibly simple. For example, if your Puppeteer code looked like this:

import { chromium } from 'playwright';

(async () => {
  const browser = await chromium.launch();
  const page = await browser.newPage();
  await page.goto('https://example.com');
  console.log(await page.title());
  await browser.close();
})();

All you need to do is modify one line and swap the launch() method with the connection URL of the AutoScraper Scraping Browser. With just that change, you get the same functionality but with the power of AutoScraper‘s infrastructure behind it. Here’s the updated code:

import { chromium } from 'playwright';

(async () => {
  const connectionURL = 'wss://api.autoscraper.pro/browser?apiKey=YOUR_API_KEY&proxy_country=us';
  const browser = await chromium.connectOverCDP(connectionURL);
  const page = await browser.newPage();
  await page.goto('https://example.com');
  console.log(await page.title());
  await browser.close();
})();

And that’s it! With just a single change, you’re now using AutoScraper Scraping Browser, which is fully equipped with the scalability, IP rotation, and global access that comes with our service.

Was this page helpful?

Previous
Puppeteer Integration