> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zenrows.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> The Zenrows HTTP API serves Fetch and Extract (extract=auto) at https://api.zenrows.com/v1/, Crawl at https://api.zenrows.com/v1/crawls, and Batch at https://async.api.zenrows.com/v1. Fetch, Extract, Crawl and Batch are described in OpenAPI 3.1 at https://www.zenrows.com/openapi.json and listed in the RFC 9727 API catalog at https://www.zenrows.com/.well-known/api-catalog. Every endpoint also has its own page under /api-reference with its schema. Use the spec for exact parameter names and types. Crawl's endpoints, parameters and errors are also at https://docs.zenrows.com/crawl/endpoints.md. To call Zenrows from an agent, connect the MCP server at https://mcp.zenrows.com/mcp. To search these docs from an agent, connect the docs MCP server at https://docs.zenrows.com/mcp. Agent skills for Zenrows are published at https://github.com/ZenRows/cli and install with `npx skills add ZenRows/cli`.

# How to Integrate Puppeteer with Zenrows

> Configure Puppeteer with Zenrows residential proxies and the Zenrows Browser to bypass anti-bot systems and scrape dynamic JavaScript websites.

Puppeteer is the most popular headless browser library in JavaScript, but anti-bot solutions can easily detect and prevent it from accessing web pages. Avoid that limitation with a Zenrows Puppeteer integration!

## Use Zenrows' Proxies in Puppeteer to Avoid Blocks

Zenrows offers residential proxies in 190+ countries that auto-rotate the IP address for you and offer Geolocation and http/https protocols. Integrate them into Puppeteer to appear as a different user every time so that your chances of getting blocked are reduced exponentially.

You have three ways to get a proxy with Zenrows, one is via [Residential Proxies](https://docs.zenrows.com/legacy/residential-proxies/introduction.md), where you get our proxy, and it's charged by the bandwidth; the other way is via Fetch's Premium Proxy, which is our residential proxy for the API, and you are charged by the request, depending on the params you choose; and the third is by using the [Zenrows Browser](https://docs.zenrows.com/browser-sessions/get-started/puppeteer.md) where you can integrate into your code with just one line of code.
\[!WARNING] For this tutorial, we'll focus on the Residential Proxies, the recommended Zenrows proxy for Puppeteer. In case you already have a running Puppeteer code, consider testing the [Zenrows Browser](https://docs.zenrows.com/browser-sessions/get-started/puppeteer.md).

After logging in, you'll get redirected to the Request Playground page, then go to the Proxies Generator page and create your proxy:

[Open the proxy generator](https://app.zenrows.com/configure/residential-proxies)

![Zenrows Residential Proxies Generator Page](https://mintcdn.com/zenrows/bpr0c_CycI-XglbC/images/proxy_generator.png?fit=max\&auto=format\&n=bpr0c_CycI-XglbC\&q=85\&s=fdfbcb9b7c71f61ed895c0e8ecb918df)

Select your Proxy Username, Proxy Country, Protocol, and Sticky TTL. Finally, copy your Proxy URL or use the cURL example at the bottom of the page.

```bash theme={"theme":"css-variables"}
http://<YOUR_USERNAME>:<YOUR_PASSWORD>@superproxy.zenrows.com:1337
```

The target site of this tutorial section will be [httpbin.io/ip](https://httpbin.io/ip), an endpoint that returns the origin IP of the incoming request. You'll use it to verify that Zenrows is working.

Consider the following basic Puppeteer script. It launches a headless browser, navigates to a target URL, and extracts the page's content (in this case, the IP address returned by the API endpoint).

```javascript scraper.js theme={"theme":"css-variables"}
import puppeteer from "puppeteer";

(async () => {
    // Launch Chrome or Chromium in headless mode
    // and open a new blank page
    const browser = await puppeteer.launch();
    const page = await browser.newPage();

    // Visit the target URL
    await page.goto("https://httpbin.io/ip");

    // Retrieve the page content and log it
    const body = await page.waitForSelector("body");
    const response = await body.getProperty("textContent");
    const jsonResponse = await response.jsonValue();
    console.log(jsonResponse);

    await browser.close();
})();
```

## Configure your Residential Proxy in Puppeteer

To use authenticated residential proxies with Puppeteer, you'll need to use Puppeteer's `--proxy-server` flag and then `page.authenticate` with username and password.

**1. Configure the Proxy**

To use Zenrows' premium proxy with Puppeteer, you need to anonymize the proxy URL provided by Zenrows. Replace `<YOUR_USERNAME>` and `<YOUR_PASSWORD>` with your actual Zenrows proxy credentials.

```javascript scraper.js theme={"theme":"css-variables"}
const browser = await puppeteer.launch({
  args: [`--proxy-server=superproxy.zenrows.com:1337`],
});
const page = await browser.newPage();
await page.authenticate({username: '<YOUR_USERNAME>', password: '<YOUR_PASSWORD>'});
```

**2. Launch Puppeteer with the Configured Proxy**

Use the anonymized proxy URL to launch Puppeteer:

```javascript scraper.js theme={"theme":"css-variables"}
import puppeteer from "puppeteer";

(async () => {
    // Launch a headless Chromium instance with Zenrows Residential Proxies configured
    const browser = await puppeteer.launch({
        args: [`--proxy-server=superproxy.zenrows.com:1337`],
    });
    const page = await browser.newPage();
    await page.authenticate({username: '<YOUR_USERNAME>', password: '<YOUR_PASSWORD>'});

    // Visit the target URL
    await page.goto("https://httpbin.io/ip");

    // Retrieve the page content and log it
    const body = await page.waitForSelector("body");
    const response = await body.getProperty("textContent");
    const jsonResponse = await response.jsonValue();
    console.log(jsonResponse);

    // Release resources
    await browser.close();
})();
```

**3. Run Your Script**

Execute your script using Node.js:

```bash theme={"theme":"css-variables"}
node scraper.js
```

## Troubleshooting

### Chrome Not Found Error

If you encounter the error `Error: Could not find Chrome`, it indicates that Puppeteer is unable to locate the Chrome or Chromium browser on your system. This issue often arises when the browser is installed in a non-standard location or if you're using a custom installation of Chrome.

To resolve this issue, explicitly specify the path to the Chrome executable in your Puppeteer configuration. You can do this by setting the `executablePath` option to the correct path where Chrome is installed on your system.

```javascript scraper.js theme={"theme":"css-variables"}
const browser = await puppeteer.launch({
  executablePath: '/your/path/to/chrome-or-chromium',
  args: [`--proxy-server=superproxy.zenrows.com:1337`],
});
```

Replace `/your/path/to/chrome-or-chromium` with the actual path to the Chrome executable on your machine.

### Invalid SSL Certificate

You might encounter a `net::ERR_CERT_AUTHORITY_INVALID` error due to SSL certificate issues. Configure Puppeteer to ignore SSL certificate errors by adding the following flag to the `launch` options to resolve this.

```javascript scraper.js theme={"theme":"css-variables"}
const browser = await puppeteer.launch({
  args: [`--proxy-server=superproxy.zenrows.com:1337`],
  ignoreHTTPSErrors: true
});
```

This allows Puppeteer to access any HTTPS page without SSL certificate issues.

### Stopped by Bot Detection with Puppeteer: CAPTCHAs, WAFs, and Beyond

Many websites employ advanced anti-bot measures like CAPTCHAs and Web Application Firewalls (WAFs) to prevent automated scraping. Simply using proxies may not be enough to bypass these protections.

Instead of relying solely on Puppeteer, consider using Zenrows' Fetch, which provides:

* **JavaScript Rendering and Interaction Simulation:** Similar to Puppeteer but optimized with anti-bot bypass capabilities.
* **Comprehensive Anti-Bot Toolkit:** Zenrows offers advanced tools to overcome complex anti-scraping solutions.

[Open the Playground](https://app.zenrows.com/fetch)

## Pricing

Zenrows operates on a bandwidth usage model on the Residential Proxies; it is pay-per-success on Fetch (that means you only pay for requests that produce the desired result).

To optimize your scraper's success rate, fully replace Puppeteer with Zenrows. Different pages on the same site may have various levels of protection, but using the parameters recommended above will ensure that you are covered.

Zenrows offers a free plan (5,000 credits/month, no card required) and paid plans starting at \$19/month. For more detailed information, please refer to our [pricing page](https://www.zenrows.com/pricing).

## Frequently Asked Questions (FAQs)

> [accordion] Why do I need a proxy for Puppeteer?
>
> Puppeteer is widely recognized by websites' anti-bot systems, which can block your requests. Using residential proxies from Zenrows allows you to rotate IP addresses and appear as a legitimate user, helping to bypass these restrictions and reduce the chances of being blocked.

> [accordion] How do I know if my proxy is working?
>
> You can test the proxy connection by running the script provided in the tutorial and checking the output from `httpbin.io/ip`. If the proxy is working, the response will display a different IP address than your local machine's.

> [accordion] What should I do if my requests are blocked?
>
> Many websites employ advanced anti-bot measures, such as CAPTCHAs and Web Application Firewalls (WAFs), to prevent automated scraping. Simply using proxies may not be enough to bypass these protections.
>
> Instead of relying solely on proxies, consider using Zenrows' Fetch, which provides:
>
> * **JavaScript Rendering and Interaction Simulation:** Optimized with anti-bot bypass capabilities.
> * **Comprehensive Anti-Bot Toolkit:** Zenrows offers advanced tools to overcome complex anti-scraping solutions.
>
> [Open the Playground](https://app.zenrows.com/fetch)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.