Skip to main content
Core and Advanced plans are no longer available for purchase. Please consider migrating to the all-in-one Web Scraper API; check out the guide here.
Scraper APIs support performing a number of browser actions before retrieving a desired result.

Actions

click

NameArgumentsDescription
clickSelectors: type:“xpath”/“css”/“text” value: stringPerforms a click action on a specified element and waits a set count of seconds.
Example:
{
    "target": "universal",
    "url": "https://www.yahoo.com/",
    "browser_actions": [
        {
            "type": "click",
            "selector": {
              "type": "xpath",
              "value": "//button"
            }
        }
    ]
}

input

NameArgumentsDescription
inputSelectors: *type: “xpath”/“css”/“text” *value: string value: stringInserts text into a specified input element on the page.
Example:
{
    "target": "universal",
    "url": "https://www.yahoo.com/",
    "browser_actions": [
        {
            "type": "input",
            "selector": {
                "type": "xpath",
                "value": "//input"
            },
	"value": "Hello world"	
        }
    ]
}

scroll

NameArgumentsDescription
scrollx: integer y: integerScrolls the content of a page a a specified number of pixels.
Example:
{
    "target": "universal",
    "url": "https://www.yahoo.com/",
    "browser_actions": [
        {
            "type": "scroll",
            "x": "0",
            "y": "300"
        }
    ]
}

scroll_to_bottom

NameArgumentsDescription
scroll_to_bottomtimeout_s: integerScrolls down the page for a set amount of seconds.
Example:
{
    "target": "universal",
    "url": "https://www.yahoo.com/",
    "browser_actions": [
        {
            "type": "scroll_to_bottom",
            "timeout_s": 5
        }
    ]
}

wait

NameArgumentsDescription
waitwait_time_s: integerPauses for a specified number of seconds.
Example:
{
    "target": "universal",
    "url": "https://www.yahoo.com/",
    "browser_actions": [
        {
            "type": "wait",
            "wait_time_s": 5
        }
    ]
}

wait_for_element

NameArgumentsDescription
wait_for_elementSelectors: *type: “xpath”/“css”/“text” *value: string timeout_s: integerWaits for a specified duration for element to load.
Example:
{
    "target": "universal",
    "url": "https://www.yahoo.com/",
    "browser_actions": [
        {
            "type": "wait_for_element",
            "selector": {
                "type": "css",
                "value": ".submit-button"
            },
	"timeout_s": 5
        }
    ]
}

fetch_resource

fetch_resource cannot be combined with any other instructions and should be used with separate requests.
NameArgumentsDescription
fetch_resourcefilter: regex on_error:“error”/“skip”Retrieves the first Fetch or XHR resource that matches the specified pattern
Example:
{
    "target": "universal",
    "url": "https://www.yahoo.com/",
    "browser_actions": [
        {
            "type": "fetch_resource",
            "filter": "https://api.example.com/products/*",          
            "on_error": "error"
        }
    ]
}

General Arguments

Arguments available for all actions above

type

NameDescription
typeType of browser action used

timeout_s

NameDescription
timeout_sHow much time in seconds to wait at max until the execution of the action is terminated.

wait_time_s

NameDescription
wait_time_sHow much time in seconds to use explicitly to execute the action.

on_error

NameDescription
on_errorIndicates what to do with actions in case they fail: “error”: Stops the execution of browser actions. “skip”: Continues with the next action.

Fetching a Network Request

If a website populates content by fetching a JSON object, you can scrape just the network request and thus avoid having to deal with HTML altogether. To do this, you can use the fetch_resource browser action, as shown below.
fetch_resource cannot be combined with any other instructions and can only be used with separate requests.
For example, when loading yahoo.com and opening the Network tab, we can see an exp.json file being loaded:
If you wish to scrape just the contents of this request, you can use the fetch_resource browser action. Note that filter is a regular expression that matches the filename:
{
    "target": "universal",
    "url": "https://www.yahoo.com/",
    "browser_actions": [
        {
            "type": "fetch_resource",
            "filter": "/ybar/exp"
        }
    ]
}
Results:
{
    "results": [
        {
            "content": "{\n    \"expCount\":5,\n    \"selection\":\"individual\",\n ... }",
            "status_code": 200,
            "url": "https://example.com/api/product/1",
            "task_id": "7131940420107377665",
            "created_at": "2023-11-19 09:46:41",
            "updated_at": "2023-11-19 09:47:08"
        }
    ]
}

Support

Need help or just want to say hello? Our support is available 24/7.
You can also reach us anytime via email at support@decodo.com.

Feedback

Can’t find what you’re looking for? Request an article!
Have feedback? Share your thoughts on how we can improve.