# Segmentação por geolocalização

Você pode especificar um local para sua sessão do Headless Browser adicionando o `p_cc`, `p_city`, ou `p_state` parâmetro à sua URL de conexão:

* `p_cc` – seleciona o país, usando um código de país de 2 letras (por exemplo, US, DE, FR). Se nenhum país for especificado, o sistema atribuirá automaticamente um com base na disponibilidade.
* `p_city` – seleciona a cidade escrita em letras minúsculas (por exemplo, berlin, los\_angeles, etc.). Você também deve especificar `p_cc` ou `p_state`
* `p_state` – seleciona um estado (somente para os EUA) quando usado como um nome em letras minúsculas (por exemplo, texas, ohio)

Aqui estão os exemplos de código para segmentação por país:

{% tabs %}
{% tab title="Python (Playwright)" %}

```python
from playwright.sync_api import sync_playwright

username = "your-username"
password = "your-password"
endpoint = "ubc.oxylabs.io"
cc = "US"  # Replace with desired 2-letter country code
browser_url = f"wss://{username}:{password}@{endpoint}?p_cc={cc}"

with sync_playwright() as p:
    browser = p.chromium.connect_over_cdp(browser_url)
    page = browser.new_page()
    page.goto('https://example.com')
    browser.close()
```

{% endtab %}

{% tab title="JavaScript (Playwright)" %}

```javascript
import { chromium } from 'playwright';

(async () => {
    const username = 'your-username';
    const password = 'your-password';
    const endpoint = 'ubc.oxylabs.io';
    const cc = 'US';  // Replace with desired 2-letter country code
    const browserUrl = `wss://${username}:${password}@${endpoint}?p_cc=${country}`;

    const browser = await chromium.connectOverCDP(browserUrl);
    const page = await browser.newPage();
    await page.goto('https://example.com');
    await browser.close();
})();
```

{% endtab %}

{% tab title="JavaScript (Puppeteer)" %}

```javascript
import puppeteer from 'puppeteer';

(async () => {
    const username = 'your-username';
    const password = 'your-password';
    const endpoint = 'ubc.oxylabs.io';
    const cc = 'US';  // Replace with desired 2-letter country code
    const browserUrl = `wss://${username}:${password}@${endpoint}?p_cc=${country}`;

    const browser = await puppeteer.connect({
        browserWSEndpoint: browserUrl
    });
    const page = await browser.newPage();
    await page.goto('https://example.com');
    await browser.close();
})();
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
**Observação:** se `p_state` e `p_cc` forem ambos especificados, `p_state` tem prioridade e `p_cc` é ignorado.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.oxylabs.io/products/pt-br/headless-browser/features/geolocation-targeting.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
