> ## 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.

# Country Targeting for ZenRows Scraping Browser

> Learn how to configure country-level geo-targeting in ZenRows Scraping Browser to access localized content and geo-restricted websites.

ZenRows Scraping Browser enables precise country-level targeting for your web scraping operations, letting you access content as if you were browsing from a specific country. This is essential for geo-restricted content, localized pricing, and market research across nations.

## What is Country Targeting?

Country-targeting routes your scraping requests through residential IP addresses from a specific country, providing the most precise geolocation control available. Unlike world region targeting, which covers broad areas, country targeting gives you IPs from individual nations.

**Key benefits:**

* Access country-specific content and services
* Accurate localized pricing and product data
* Compliance testing for legal jurisdictions
* Ad verification and fraud prevention by country
* Market research with country-level precision

<Note>
  Auto-rotate and Residential IPs are pre-configured and enabled by default for all ZenRows Scraping Browser users. Country targeting works seamlessly with these features to provide optimal performance.
</Note>

## How to Configure Country Targeting

You can configure country targeting in two ways:

* **ZenRows SDK:** Recommended for most users (simplest, most robust)
* **Direct WebSocket URL:** For advanced or custom integrations

<Tabs>
  <Tab title="Puppeteer">
    For custom integrations or direct control, specify the country using the `proxy_country` parameter in the WebSocket URL.

    ```bash theme={null}
    wss://browser.zenrows.com?apikey=YOUR_ZENROWS_API_KEY&proxy_country=es
    ```

    <CodeGroup>
      ```javascript Node.js theme={null}
      const puppeteer = require('puppeteer-core');
      const wsUrl = 'wss://browser.zenrows.com?apikey=YOUR_ZENROWS_API_KEY&proxy_country=es';

      (async () => {
          const browser = await puppeteer.connect({ browserWSEndpoint: wsUrl });
          const page = await browser.newPage();
          await page.goto('https://example.com');
          console.log(await page.title());
          await browser.close();
      })();
      ```

      ```python Python theme={null}
      import asyncio
      from pyppeteer import connect

      async def main():
          ws_url = 'wss://browser.zenrows.com?apikey=YOUR_ZENROWS_API_KEY&proxy_country=es'
          browser = await connect(browserWSEndpoint=ws_url)
          page = await browser.newPage()
          await page.goto('https://example.com')
          print(await page.title())
          await browser.close()

      asyncio.get_event_loop().run_until_complete(main())
      ```
    </CodeGroup>

    ZenRows supports residential IPs from over 100 countries worldwide. For the complete list and codes, see our [Premium Proxy Countries List](/first-steps/faq#what-is-geolocation-and-what-are-all-the-premium-proxy-countries).

    **Most Popular:**

    * **us** - United States
    * **gb** - United Kingdom
    * **br** - Brazil
    * **de** - Germany
    * **ca** - Canada
    * **au** - Australia
    * **fr** - France
    * **in** - India
    * **es** - Spain
    * **it** - Italy
    * **nl** - Netherlands
  </Tab>

  <Tab title="Playwright">
    For custom integrations or direct control, specify the country using the `proxy_country` parameter in the WebSocket URL.

    ```bash theme={null}
    wss://browser.zenrows.com?apikey=YOUR_ZENROWS_API_KEY&proxy_country=es
    ```

    <CodeGroup>
      ```javascript Node.js theme={null}
      const { ScrapingBrowser, ProxyCountry } = require('@zenrows/scraping-browser');
      const { chromium } = require('playwright');

      (async () => {
          const scrapingBrowser = new ScrapingBrowser({ apiKey: 'YOUR_ZENROWS_API_KEY' });
          // Target Germany
          const connectionURL = scrapingBrowser.getConnectURL({
              proxy: { location: ProxyCountry.DE },
          });
          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();
      })();
      ```

      ```python Python theme={null}
      import asyncio
      from playwright.async_api import async_playwright

      async def main():
          ws_url = 'wss://browser.zenrows.com?apikey=YOUR_ZENROWS_API_KEY&proxy_country=es'
          async with async_playwright() as p:
              browser = await p.chromium.connect_over_cdp(ws_url)
              page = await browser.new_page()
              await page.goto('https://example.com')
              print(await page.title())
              await browser.close()

      asyncio.run(main())
      ```
    </CodeGroup>

    ZenRows supports residential IPs from over 100 countries worldwide. For the complete list and codes, see our [Premium Proxy Countries List](/first-steps/faq#what-is-geolocation-and-what-are-all-the-premium-proxy-countries).

    **Most Popular:**

    * **us** - United States
    * **gb** - United Kingdom
    * **br** - Brazil
    * **de** - Germany
    * **ca** - Canada
    * **au** - Australia
    * **fr** - France
    * **in** - India
    * **es** - Spain
    * **it** - Italy
    * **nl** - Netherlands
  </Tab>

  <Tab title="ZenRows SDK">
    The ZenRows SDK offers the easiest way to configure country targeting, with built-in error handling and connection management.

    <CodeGroup>
      ```javascript Node.js Puppeteer theme={null}
      const { ScrapingBrowser, ProxyCountry } = require('@zenrows/scraping-browser');
      const puppeteer = require('puppeteer-core');

      (async () => {
          const scrapingBrowser = new ScrapingBrowser({ apiKey: 'YOUR_ZENROWS_API_KEY' });
          // Target Spain
          const connectionURL = scrapingBrowser.getConnectURL({
              proxy: { location: ProxyCountry.ES },
          });
          const browser = await puppeteer.connect({ browserWSEndpoint: connectionURL });
          const page = await browser.newPage();
          await page.goto('https://example.com');
          console.log(await page.title());
          await browser.close();
      })();
      ```

      ```javascript Node.js Playwright theme={null}
      const { ScrapingBrowser, ProxyCountry } = require('@zenrows/scraping-browser');
      const { chromium } = require('playwright');

      (async () => {
          const scrapingBrowser = new ScrapingBrowser({ apiKey: 'YOUR_ZENROWS_API_KEY' });
          // Target Germany
          const connectionURL = scrapingBrowser.getConnectURL({
              proxy: { location: ProxyCountry.DE },
          });
          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();
      })();
      ```
    </CodeGroup>

    **Popular SDK Country Options:**

    * `ProxyCountry.US` - United States
    * `ProxyCountry.GB` - United Kingdom
    * `ProxyCountry.BR` - Brazil
    * `ProxyCountry.DE` - Germany
    * `ProxyCountry.FR` - France
    * `ProxyCountry.IN` - India
    * `ProxyCountry.ES` - Spain
    * `ProxyCountry.CA` - Canada
    * `ProxyCountry.AU` - Australia
    * `ProxyCountry.JP` - Japan
  </Tab>
</Tabs>

<Frame>
  <img src="https://static.zenrows.com/content/res_proxy_country_9f8e255bf9.png" style={{ borderRadius: '0.5rem' }} alt="Country Targeting Configuration Interface" />
</Frame>

## Best Practices

**Choosing the Right Country:**

* Select countries based on your target market or content
* Consider local business hours and time zones for time-sensitive scraping
* Test with multiple countries to understand regional content differences

**SDK vs Direct Connection:**

* **Use the SDK** for most projects. It offers better error handling and automatic retries
* **Direct WebSocket** is for custom frameworks or specific connection control

**Performance Optimization:**

* Some countries have larger IP pools and better performance
* Monitor success rates and adjust the country selection accordingly
* Use fallback countries if your primary choice has issues

## Troubleshooting

**Common Issues and Solutions:**

**Country Code Errors:**

* Use the correct ISO country code (e.g., 'es' for Spain)
* Check the country list to ensure support
* Use lowercase codes in direct WebSocket connections

**No Content Differences:**

* Some sites may not vary by country. Test manually by accessing the website
* Try different countries to verify geo-targeting
* Some sites use detection beyond IP geolocation

**Connection Issues:**

* Some countries may have smaller IP pools. Try alternative countries
* Monitor the response error for indications that may help
* Use world region targeting if country-level access is problematic

<Tip>
  You cannot use both world region and country targeting at the same time. Select the level of precision you require, whether broad regional coverage or targeted to a specific country.
</Tip>

## Next Steps

* Explore [Session TTL Configuration](/scraping-browser/features/session-ttl) to control browser session duration
* Learn about [World Region Targeting](/scraping-browser/features/world-region) for broader coverage
* See the <a href="https://github.com/ZenRows/browser-js-sdk" target="_blank" rel="noopener noreferrer nofollow">ZenRows SDK Repository</a> for advanced features and examples
* Review [Premium Proxy Countries List](/first-steps/faq#what-is-geolocation-and-what-are-all-the-premium-proxy-countries) for all available countries
* Check the [Practical Use Cases](/scraping-browser/help/practical-use-cases) for real world examples
