> For the complete documentation index, see [llms.txt](https://developers.oxylabs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.oxylabs.io/products/es/headless-browser/tipo-de-dispositivo.md).

# Tipo de dispositivo

Usa los parámetros de geolocalización y enrutamiento de proxy directamente en la URL de conexión WebSocket para enrutar tus sesiones automatizadas de Headless Browser a través de regiones geográficas específicas y controlar el uso de tu IP de proxy.

## Parámetros de geolocalización

Puedes dirigirte a ubicaciones geográficas específicas por país, estado o ciudad usando tres parámetros de consulta principales.

### País

<table data-header-hidden><thead><tr><th width="90"></th><th></th></tr></thead><tbody><tr><td><code>p_cc</code></td><td>Código de país de 2 letras (p. ej., <code>US</code>, <code>DE</code>, <code>FR</code>). Si no se especifica ningún país, se asigna automáticamente según la disponibilidad.</td></tr></tbody></table>

```
wss://USER:PASS@ubc.oxylabs.io?p_cc=US
```

### Ciudad

<table data-header-hidden><thead><tr><th width="90"></th><th></th></tr></thead><tbody><tr><td><code>p_city</code></td><td>Nombre de la ciudad escrito en minúsculas (p. ej., <code>berlin</code>, <code>los_angeles</code>). También debes especificar ya sea <code>p_cc</code> o <code>p_state</code>.</td></tr></tbody></table>

```
wss://USER:PASS@ubc.oxylabs.io?p_cc=US&p_city=new_york
```

{% hint style="info" %}
El targeting a nivel de ciudad funciona como *preferencia de mejor esfuerzo*. Si el grupo de proxies residenciales no tiene un proxy disponible en la ubicación exacta solicitada, cambia automáticamente al alcance del país.
{% endhint %}

### Estado (solo EE. UU.)

<table data-header-hidden><thead><tr><th width="90"></th><th></th></tr></thead><tbody><tr><td><code>p_state</code></td><td>Nombre del estado de EE. UU. en minúsculas (p. ej., <code>texas</code>, <code>ohio</code>). Consulta la lista completa de  <a href="https://content.gitbook.com/content/BQ7Zf9paoN3FTeGcyfY1/blobs/cVjpiu1GKicluiVIT9og/us_states.txt">estados admitidos</a>.</td></tr></tbody></table>

```
wss://USER:PASS@ubc.oxylabs.io?p_state=texas&p_city=houston
```

{% hint style="info" %}
**Nota:** Si `p_state` y `p_cc` se especifican ambos, `p_state` tiene prioridad y `p_cc` se ignora.
{% endhint %}

## Selección de proxy (proxies persistentes)

De forma predeterminada, la puerta de enlace proxy asigna una nueva IP de salida a cada sesión única de conexión del navegador. Como alternativa, puedes fijar una IP de salida residencial específica en intentos continuos de conexión del navegador incluyendo el `proxy_resi_ses_id` y `proxy_resi_ses_time` parámetros.

<table><thead><tr><th width="181">Parámetro</th><th width="479">Descripción</th><th width="83">Tipo</th></tr></thead><tbody><tr><td><code>proxy_resi_ses_id</code></td><td>Nombre de seguimiento de sesión alfanumérico de 3 a 36 caracteres.</td><td>cadena</td></tr><tr><td><code>proxy_resi_ses_time</code></td><td>Número de minutos para mantener fija la IP de salida del proxy residencial. Mín. 1 minuto, máx. 1440 minutos (24 horas).</td><td>entero</td></tr></tbody></table>

```bash
# Example: Pin a US-based IP for a 60 minutes
wss://USER:PASS@ubc.oxylabs.io?p_cc=US&proxy_resi_ses_id=unique_job_id_101&proxy_resi_ses_time=60
```

{% hint style="warning" %}
To maintain the exact same exit IP across consecutive connections, you must pass identical values for both `proxy_resi_ses_id` y `proxy_resi_ses_time` in every subsequent URL string.
{% endhint %}

## Ejemplos de código

Los siguientes ejemplos muestran cómo construir cadenas de conexión que aplican segmentación geográfica junto con restricciones persistentes de IP de proxy residencial.

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

```python
from playwright.sync_api import sync_playwright

username = "USERNAME_abc12"
password = "PASSWORD"
endpoint = "ubc.oxylabs.io"

# Target New York city and pin the residential IP for 30 minutes
geolocation = "p_cc=US&p_city=new_york"
sticky_proxy = "proxy_resi_ses_id=scrape_session_404&proxy_resi_ses_time=30"
browser_url = f"wss://{username}:{password}@{endpoint}?{geolocation}&{sticky_proxy}"

with sync_playwright() as p:
    browser = p.chromium.connect_over_cdp(browser_url)
    page = browser.new_page()
    page.goto("https://ip.oxylabs.io/location")
    print(page.title())
    browser.close()
```

{% endtab %}

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

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

const username = "USERNAME_abc12";
const password = "PASSWORD";
const endpoint = "ubc.oxylabs.io";

// Target Texas state and pin the residential IP for 60 minutes
const geolocation = "p_state=texas&p_city=houston";
const sticky_proxy = "proxy_resi_ses_id=scrape_session_404&proxy_resi_ses_time=60";
const browserUrl = `wss://${username}:${password}@${endpoint}?${geolocation}&${sticky_proxy}`;

(async () => {
    const browser = await chromium.connectOverCDP(browserUrl);
    const page = await browser.newPage();
    await page.goto("https://ip.oxylabs.io/location");
    console.log(await page.title());
    await browser.close();
})();
```

{% endtab %}

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

```javascript
import puppeteer from 'puppeteer';

(async () => {
    const username = 'USERNAME';
    const password = 'PASSWORD';
    const endpoint = 'ubc.oxylabs.io';
    
    // Target Texas state and pin the residential IP for 60 minutes
    const geolocation = "p_state=texas&p_city=houston";
    const sticky_proxy = "proxy_resi_ses_id=scrape_session_404&proxy_resi_ses_time=60";
    const browserUrl = `wss://${username}:${password}@${endpoint}?${geolocation}&${sticky_proxy}`;

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

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://developers.oxylabs.io/products/es/headless-browser/tipo-de-dispositivo.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
