Developers

Web Scraping API

Reference

Browser instructions

Run ordered browser actions before returning rendered content.

Define an action sequence

Send a browser_instructions array with render: "html" or render: "png". Use CSS, XPath or text selectors. Each instruction finishes before the next one runs.

Click and wait for content
{
  "source": "universal",
  "url": "https://example.com/",
  "render": "html",
  "browser_instructions": [
    {
      "type": "click",
      "selector": {
        "type": "css",
        "value": "button.load-more"
      }
    },
    {
      "type": "wait_for_element",
      "selector": {
        "type": "css",
        "value": ".loaded-items"
      }
    }
  ]
}

Supported instructions

typeArgumentsBehavior
clickselectorClick the selected element.
inputselector, valueEnter text into an input.
scrollx, yScroll by a pixel offset.
scroll_to_bottomNo selectorScroll through the page.
waitwait_time_sWait for a fixed interval.
wait_for_elementselectorWait for a matching element.
fetch_resourceResource selectorReturn the first matching Fetch/XHR resource.

Scroll horizontally to read all columns.

Timing and failure behavior

Use timeout_s to bound an action and wait_time_s to delay the next action. on_error: "error" stops instruction execution; on_error: "skip" continues to the next step. Choose skip only when the missing action does not invalidate the result.

Fetch a browser resource

fetch_resource returns the first matching Fetch/XHR resource instead of the page HTML. For a record of multiple browser requests, use xhr: true and inspect the XHR output type.

Search documentation

Search guides, products and reference pages.