# Puppeteer stealth

Enabling Puppeteer Stealth is a configuration that makes the browser behave more «human-like,» avoiding detection as a bot by websites. This is useful for tasks like web automation or scraping without triggering anti-bot mechanisms. Instead of just launching a browser, you can enable the Stealth option in Puppeteer to improve the discretion of actions.

#### Enabling Puppeteer Stealth in the HTTP API <a href="#id-0-toc-title" id="id-0-toc-title"></a>

To enable Puppeteer Stealth, you pass a boolean value in the configuration sent to the HTTP API. This allows the browser to apply specific adjustments that mimic human behavior during execution, such as modifying network headers and changing the browser’s `navigator` properties, among others.

#### Example in C# using CloudBrowser’s HTTP API <a href="#id-1-toc-title" id="id-1-toc-title"></a>

Here’s a C# example that enables Puppeteer Stealth when launching a remote browser:

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

public class Program
{
    public static async Task Main(string[] args)
    {
        var serverUrl = "https://production.cloudbrowser.ai/api/v1/Browser/OpenAdvanced";
        var apiToken = "your-api-token"; // Replace with your actual API token

        var requestBody = new
        {
            Stealth = true // Pass Stealth as true in the request body
        };

        var jsonContent = new StringContent(JsonConvert.SerializeObject(requestBody), Encoding.UTF8, "application/json");

        // Create an HttpClient and include the API token in the request headers
        var httpClient = new HttpClient();
        httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiToken);

        // Request the WebSocket endpoint of the remote browser
        var response = await httpClient.PostAsync(serverUrl, jsonContent);
        
        // Get address value
        var responseContent = await response.Content.ReadAsStringAsync();
        dynamic jsonResponse = JsonConvert.DeserializeObject(responseContent);
        var browserWSEndpoint = jsonResponse.address;
        
        // Connect to the remote browser
        var browser = await Puppeteer.ConnectAsync(new ConnectOptions
        {
            BrowserWSEndpoint = browserWSEndpoint,
        });

        // Create a new page
        var page = await browser.NewPageAsync();

        // Navigate to a URL to verify the IP
        await page.GoToAsync("https://ifconfig.me");

        // Close the browser
        await browser.CloseAsync();
    }
}
```


---

# 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://cloudbrowser.gitbook.io/docs/configurations/puppeteer-stealth.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.
