> 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/web-unblocker/custom-browser-instructions/browser-instructions-beta.md).

# Browser instructions (Beta)

When using Custom Browser Instructions, you can define your own specific browser instructions that are executed when rendering JavaScript.

{% hint style="success" %}
Generate **Browser instructions automatically** in the [**Web Scraper API Playground**](https://dashboard.oxylabs.io/?route=/api-playground) on the Oxylabs dashboard. Set up browser actions, test them, and export the generated instructions in JSON format.&#x20;
{% endhint %}

### How to use it?

To use browser instructions, provide a set of `browser_instructions` when creating a job.

Let’s say you want to search for the term `pizza boxes` in a website.

<figure><img src="/files/8M3x0IFFR7DIFuisgQNz" alt=""><figcaption></figcaption></figure>

An example job parameters would look as follows:

{% code overflow="wrap" %}

```bash
curl -k -x https://unblock.oxylabs.io:60000 \
-U 'USERNAME:PASSWORD' \
'https://www.ebay.com' \
-H 'x-oxylabs-render: html' \
-H "x-oxylabs-browser-instructions: [{\"type\":\"input\",\"value\":\"pizza boxes\",\"selector\":{\"type\":\"xpath\",\"value\":\"\/\/input[@class='gh-tb ui-autocomplete-input']\"}},{\"type\":\"click\",\"selector\":{\"type\":\"xpath\",\"value\":\"\/\/input[@type='submit']\"}},{\"type\":\"wait\",\"wait_time_s\":5}]"
```

{% endcode %}

**Step 1.** You must provide the `x-oxylabs-render: html` parameter.

**Step 2.** Browser instructions should be described in the `x-oxylabs-browser_instructions` field.

{% hint style="info" %}
The browser instructions provided as the header value must be JSON-escaped and contain no extra spaces.
{% endhint %}

The sample browser instructions above specifies that the aim is to enter a search term `pizza boxes` into a search field, click `search` button and wait for 5 seconds for content to load.

The scraped result should look as follows:

```html
<!doctype html><html>
Content after executing the instructions      
</html>
```

Scraped HTML should look like this:

<figure><img src="/files/YwkHCo0pOyGULLoBRRRi" alt=""><figcaption></figcaption></figure>

#### Fetching browser resources <a href="#fetching-browser-resources" id="fetching-browser-resources"></a>

We provide a standalone browser instruction for fetching browser resources.

The function is defined here:

Using `fetch_resource` will result in job returning the first occurrence of a Fetch/XHR resource that matches the format provided instead of the HTML that is being targeted.

Let’s say we want to target a GraphQL resource that is fetched when visiting a product page organically in the browser. We will provide job information as such:

{% code overflow="wrap" %}

```bash
curl -k -x https://unblock.oxylabs.io:60000 \
-U 'USERNAME:PASSWORD' \
'https://www.example.com/product-page/123' \
-H 'x-oxylabs-render: html' \
-H "x-oxylabs-browser-instructions: [{\"type\": \"fetch_resource\",\"filter\": \"\/graphql\/product-info\/123\"}]"
```

{% endcode %}

These instructions will result in a result as such:

```html
{"product_id": 123, "description": "", "price": 456}
```

### List of supported browser instructions <a href="#list-of-supported-browser-instructions" id="list-of-supported-browser-instructions"></a>

{% content-ref url="/pages/JBIU0fEiNJubIFXc4JxV" %}
[List of instructions](/products/web-unblocker/custom-browser-instructions/browser-instructions-beta/list-of-instructions.md)
{% endcontent-ref %}

### Status codes <a href="#status-codes" id="status-codes"></a>

See our response codes outlined [**here**](/products/web-unblocker/response-codes.md). Status codes in regards to instructions validation are documented [**here**](/products/web-unblocker/custom-browser-instructions/browser-instructions-beta/list-of-instructions.md#instructions-validation).


---

# 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/web-unblocker/custom-browser-instructions/browser-instructions-beta.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.
