> 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/pt-br/web-scraper-api/integration-methods/proxy-endpoint.md).

# Proxy Endpoint

Envie e receba dados via o Proxy Endpoint da Oxylabs Web Scraper API. Acesse páginas de destino diretamente por meio de uma integração simples baseada em URL.

Se você já usou proxies comuns para extração de dados, integrar o método de entrega Proxy Endpoint será moleza. Tudo o que você precisa fazer é usar nosso nó de entrada como um proxy, autorizar com as credenciais da Web Scraper API e ignorar certificados. Em `cURL`, é `-k` or `--insecure`. Seus dados chegarão a você em uma conexão aberta.

Proxy Endpoint **só funciona com as fontes de dados baseadas em URL**, em que a URL completa é fornecida. Portanto, ele aceita apenas alguns parâmetros adicionais de job, que [**devem ser enviados como cabeçalhos**](#accepted-parameters).

{% hint style="warning" %}
O Proxy Endpoint não foi projetado para ser controlado por navegadores headless (por exemplo, Chromium, PhantomJS, Splash) ou suas bibliotecas de automação (por exemplo, Playwright, Selenium, Puppeteer).
{% endhint %}

### Endpoint

```
GET realtime.oxylabs.io:60000
```

### Entrada

Veja abaixo um exemplo de requisição.

{% tabs %}
{% tab title="cURL" %}

```shell
curl -k -x https://realtime.oxylabs.io:60000 \
-U 'USERNAME:PASSWORD' \
-H 'x-oxylabs-user-agent-type: desktop' \
-H 'x-oxylabs-geo-location: Germany' \
'https://www.example.com'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
from pprint import pprint

# Use suas credenciais da Web Scraper API aqui.
USERNAME, PASSWORD = 'YOUR_USERNAME', 'YOUR_PASSWORD'

# Define proxy dict.
proxies = {
  'http': f'http://{USERNAME}:{PASSWORD}@realtime.oxylabs.io:60000',
  'https': f'https://{USERNAME}:{PASSWORD}@realtime.oxylabs.io:60000'
}

# Para definir uma geo-localização, User-Agent específicos ou renderizar JavaScript
# é necessário enviar parâmetros como cabeçalhos da requisição.
headers = {
    'x-oxylabs-user-agent-type': 'desktop',
    'x-oxylabs-geo-location': 'Germany',
    #'X-Oxylabs-Render': 'html', # Descomente se quiser renderizar JavaScript dentro da página.
}

response = requests.request(
    'GET',
    'https://www.example.com',
    headers = headers, # Passe os cabeçalhos definidos.
    verify=False,  # Aceite nosso certificado.
    proxies=proxies,
)

# Imprima a página de resultado na saída padrão.
pprint(response.text)

# Salve o HTML retornado no arquivo 'result.html'.
with open('result.html', 'w') as f:
    f.write(response.text)
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
import fetch from 'node-fetch';
import { HttpsProxyAgent } from 'https-proxy-agent';

const username = 'YOUR_USERNAME';
const password = 'YOUR_PASSWORD';

const agent = new HttpsProxyAgent(
  `https://${username}:${password}@realtime.oxylabs.io:60000`
);

// O Proxy Endpoint apresenta seu próprio certificado para o site de destino, então a verificação TLS deve ser desativada
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;

const headers = {
  'x-oxylabs-user-agent-type': 'desktop',
  'x-oxylabs-geo-location': 'Germany',
}

const response = await fetch('https://www.example.com', {
  method: 'get',
  headers: headers,
  agent: agent,
});

console.log(await response.text());
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://www.example.com/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXY, 'https://realtime.oxylabs.io:60000');
curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'YOUR_USERNAME' . ':' . 'YOUR_PASSWORD');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
// Para definir uma geo-localização, User-Agent específicos ou renderizar JavaScript
// é necessário enviar parâmetros como cabeçalhos da requisição.
curl_setopt_array($ch, array(
    CURLOPT_HTTPHEADER  => array(
        'x-oxylabs-user-agent-type: desktop',
        -H 'x-oxylabs-geo-location: Germany',
        //'X-Oxylabs-Render: html', // Descomente se quiser renderizar JavaScript dentro da página.
    )
));

$result = curl_exec($ch);
echo $result;

if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close($ch);
?>
```

{% endtab %}

{% tab title="Golang" %}

```go
package main

import (
    "crypto/tls"
    "fmt"
    "io/ioutil"
    "net/http"
    "net/url"
)

func main() {
    const Username = "YOUR_USERNAME"
    const Password = "YOUR_PASSWORD"

    proxyUrl, _ := url.Parse(
        fmt.Sprintf(
            "https://%s:%s@realtime.oxylabs.io:60000",
            Username,
            Password,
        ),
    )
    customTransport := &http.Transport{Proxy: http.ProxyURL(proxyUrl)}

    // O Proxy Endpoint apresenta seu próprio certificado para o site de destino, então a verificação TLS deve ser desativada
    customTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}

    client := &http.Client{Transport: customTransport}
    request, _ := http.NewRequest("GET",
        "https://www.example.com",
        nil,
    )

    request.Header.Add("x-oxylabs-user-agent-type", "desktop")
    request.Header.Add("x-oxylabs-geo-location", "Germany")
    request.SetBasicAuth(Username, Password)
    response, _ := client.Do(request)

    responseText, _ := ioutil.ReadAll(response.Body)
    fmt.Println(string(responseText))
}

```

{% endtab %}

{% tab title="C#" %}

```csharp
using System;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;

namespace OxyApi
{
    class Program
    {
        static async Task Main(string[] args)
        {
            var webProxy = new WebProxy
            {
                Address = new Uri($"https://realtime.oxylabs.io:60000"),
                BypassProxyOnLocal = false,
                UseDefaultCredentials = false,

                Credentials = new NetworkCredential(
                userName: "YOUR_USERNAME",
                password: "YOUR_PASSWORD"
                )
            };

            var httpClientHandler = new HttpClientHandler
            {
                Proxy = webProxy,
            };

            // O Proxy Endpoint apresenta seu próprio certificado para o site de destino, então a verificação TLS deve ser desativada
            httpClientHandler.ClientCertificateOptions = ClientCertificateOption.Manual;
            httpClientHandler.ServerCertificateCustomValidationCallback =
                (httpRequestMessage, cert, cetChain, policyErrors) =>
                {
                    return true;
                };


            var client = new HttpClient(handler: httpClientHandler, disposeHandler: true);

            client.DefaultRequestHeaders.Add("x-oxylabs-user-agent-type", "desktop");
            client.DefaultRequestHeaders.Add("x-oxylabs-geo-location", "Germany");

            Uri baseUri = new Uri("https://www.example.com");
            client.BaseAddress = baseUri;

            var requestMessage = new HttpRequestMessage(HttpMethod.Get, "");

            var response = await client.SendAsync(requestMessage);
            var contents = await response.Content.ReadAsStringAsync();

            Console.WriteLine(contents);
        }
    }
}
```

{% endtab %}

{% tab title="Java" %}

```java
package org.example;

import org.apache.hc.client5.http.auth.AuthScope;
import org.apache.hc.client5.http.auth.CredentialsProvider;
import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.impl.auth.CredentialsProviderBuilder;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder;
import org.apache.hc.client5.http.ssl.NoopHostnameVerifier;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactoryBuilder;
import org.apache.hc.client5.http.ssl.TrustAllStrategy;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.message.StatusLine;
import org.apache.hc.core5.ssl.SSLContextBuilder;

import java.util.Arrays;
import java.util.Properties;


public class Main {

    public static void main(final String[] args)throws Exception {
        final CredentialsProvider credsProvider = CredentialsProviderBuilder.create()
                .add(new AuthScope("realtime.oxylabs.io", 60000), "YOUR_USERNAME", "YOUR_PASSWORD".toCharArray())
                .build();
        final HttpHost target = new HttpHost("https", "example.com", 443);
        final HttpHost proxy = new HttpHost("https", "realtime.oxylabs.io", 60000);
        try (final CloseableHttpClient httpclient = HttpClients.custom()
                .setDefaultCredentialsProvider(credsProvider)
                .setProxy(proxy)
                // O Proxy Endpoint apresenta seu próprio certificado para o site de destino, então a verificação TLS deve ser desativada
                .setConnectionManager(PoolingHttpClientConnectionManagerBuilder.create()
                        .setSSLSocketFactory(SSLConnectionSocketFactoryBuilder.create()
                                .setSslContext(SSLContextBuilder.create()
                                        .loadTrustMaterial(TrustAllStrategy.INSTANCE)
                                        .build())
                                .setHostnameVerifier(NoopHostnameVerifier.INSTANCE)
                                .build())
                        .build())
                .build()) {

            final RequestConfig config = RequestConfig.custom()
                    .build();
            final HttpGet request = new HttpGet("/");
            request.addHeader("x-oxylabs-user-agent-type","desktop");
            request.addHeader("x-oxylabs-geo-location","Germany");
            request.setConfig(config);

            System.out.println("Executing request " + request.getMethod() + " " + request.getUri() +
                    " via " + proxy + " headers: " + Arrays.toString(request.getHeaders()));

            httpclient.execute(target, request, response -> {
                System.out.println("----------------------------------------");
                System.out.println(request + "->" + new StatusLine(response));
                EntityUtils.consume(response.getEntity());
                return null;
            });
        }
    }
}
```

{% endtab %}
{% endtabs %}

### Saída

Abaixo você encontrará uma resposta de exemplo de `https://example.com`:

<details>

<summary>Resposta de exemplo</summary>

```html
<!doctype html>
<html lang="en">
<head>
<title>Example Domain</title>
<link rel="icon" href="data:,">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>body{background:#eee;width:60vw;margin:15vh auto;font-family:system-ui,sans-serif}h1{font-size:1.5em}div{opacity:0.8}a:link,a:visited{color:#348}</style>
</head>
<body>
<div>
<h1>Example Domain</h1>
<p>Este domínio é usado em exemplos de documentação sem necessidade de permissão. Evite usá-lo em operações.</p>
<p>
<a href="https://iana.org/domains/example">Saiba mais</a>
</p>
</div>
</body>
</html>
```

</details>

### Parâmetros aceitos

Ao fazer sua requisição, junto com a URL, você pode nos enviar alguns parâmetros de job que usaremos ao executar seu job. Os parâmetros de job devem ser enviados nos cabeçalhos da requisição - veja um exemplo [**aqui**](#input)**.**

Aqui está a lista de parâmetros de job que você pode enviar com requisições ao Proxy Endpoint:

| Parâmetro                        | Descrição                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `x-oxylabs-user-agent-type`      | Não há como indicar um User-Agent específico, mas você pode nos informar qual tipo de user-agent gostaria que usássemos. Uma lista de tipos de User-Agent compatíveis pode ser encontrada [**aqui**](https://developers.oxylabs.io/products/pt-br/web-scraper-api/features/http-context-and-job-management/user-agent-type.md).                                                                                                           |
| `x-oxylabs-geo-location`         | Em alguns casos, talvez seja necessário indicar a localização geográfica para a qual o resultado deve ser adaptado. Este parâmetro corresponde ao `geo_location` parâmetro, descrito separadamente na documentação de nível de origem. Os valores aceitos dependem da URL que você gostaria que extraíssemos. Leia mais [**aqui**](https://developers.oxylabs.io/products/pt-br/web-scraper-api/features/localization/proxy-location.md). |
| `x-oxylabs-render`               | Execução de JavaScript. Valores aceitos: `html` e `png`. Leia mais [**aqui**](https://developers.oxylabs.io/products/pt-br/web-scraper-api/features/js-rendering-and-browser-control.md).                                                                                                                                                                                                                                                 |
| `x-oxylabs-parse`                | Defina como true para obter saída JSON estruturada em vez do conteúdo bruto da página. Só funciona para URLs cobertas por um [**parser dedicado**](https://developers.oxylabs.io/products/pt-br/web-scraper-api/features/result-processing-and-storage/dedicated-parsers.md)**.**                                                                                                                                                         |
| `x-oxylabs-parser-type`          | Seleciona um parser explicitamente. Deve ser enviado junto com `x-oxylabs-parse: true`, e deve ser um parser que suporte a URL que você está extraindo.                                                                                                                                                                                                                                                                                   |
| `x-oxylabs-browser-instructions` | Instruções do navegador como uma string JSON. Requer `x-oxylabs-render`. Leia mais [**aqui**](https://developers.oxylabs.io/products/pt-br/web-scraper-api/features/js-rendering-and-browser-control.md#browser-instructions).                                                                                                                                                                                                            |


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developers.oxylabs.io/products/pt-br/web-scraper-api/integration-methods/proxy-endpoint.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
