# Objetivo de geolocalización

Puede especificar una ubicación para su sesión de Headless Browser agregando el `p_cc`, `p_city`, o `p_state` parámetro a tu URL de conexión:

* `p_cc` – selecciona el país, usando un código de país de 2 letras (por ejemplo, US, DE, FR). Si no se especifica ningún país, el sistema asignará automáticamente uno según la disponibilidad.
* `p_city` – selecciona la ciudad escrita en minúsculas (por ejemplo, berlin, los\_angeles, etc.). También debe especificar ya sea `p_cc` o `p_state`
* `p_state` – selecciona un estado (solo para EE. UU.) cuando se usa como un nombre en minúsculas (por ejemplo, texas, ohio)

Aquí están los ejemplos de código para la selección de 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" %}
**Nota:** si `p_state` y `p_cc` están ambos especificados, `p_state` tiene prioridad y `p_cc` se ignora.
{% 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/es/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.
