Geonode Logo light

Actions

The Scraper takes an array of actions that let you interact with the target document. Here's a list of the supported actions and how to use them:

Usage

Just add the array of actions to the "configurations" parameter of your Scraper request. For example, if you want to click on a button:

{   
    "url": ..., 
    "configurations": {
        ...,
        "js_scenario": {
            "actions": [
                {
                    "action": "click",
                    "selector": "#targetButtonId"
                }
            ]
        }
    }
        
}

And our scraper will click the button with the "#targetButtonId" selector before returning the result HTML.


Click

Clicks on the target item.

Action Parameters

  • Name
    selector
    Type
    string
    Description

    The selector of the HTML element to click. If there are multiple elements satisfying the selector, the first will be clicked.

  • Name
    options.delay
    Type
    number
    Description

    The number of milliseconds to wait before clicking the element.

  • Name
    options.button
    Type
    'left' | 'right' | 'middle' | 'back' | 'forward'
    Description

    The place of the element to click to.

  • Name
    options.clickCount
    Type
    number
    Description

    The number of times to click the element.

{
    "action": "click",
    "selector": "#targetButtonId",
    "options": {
        "delay": 1000,
        "selector": "#targetButtonId",
        "button": "middle",
        "clickCount": 1,
    }
}

Wait

Waits for a fixed amount of milliseconds.

Action Parameters

  • Name
    value
    Type
    number
    Description

    The number of milliseconds to wait.

{
    "action": "wait",
    "value": 1000,
}

Wait For

Waits for a target HTML element to appear or disappear.

Action Parameters

  • Name
    selector
    Type
    string
    Description

    The selector of the HTML element to wait for.

  • Name
    options.visible
    Type
    boolean
    Description

    A Boolean indicating whether to wait for the element to become visible.

  • Name
    options.hidden
    Type
    boolean
    Description

    A Boolean indicating whether to wait for the element to become hidden.

  • Name
    options.timeout
    Type
    number
    Description

    The maximum amount of time, in milliseconds, to wait for the element.

{
    "action": "wait_for",
    "selector": "#targetElementId",
    "options": {
        "visible": true,
        "timeout": 10000,
    }
}

Click and Wait For Navigation (Almost Here!)

Clicks on the target item and waits for the navigation triggered by the click. Only use if the click triggers a navigation.

Action Parameters

  • Name
    selector
    Type
    string
    Description

    The selector of the HTML element to click. If there are multiple elements satisfying the selector, the first will be clicked.

  • Name
    options.delay
    Type
    number
    Description

    The number of milliseconds to wait before clicking the element.

  • Name
    options.button
    Type
    'left' | 'right' | 'middle' | 'back' | 'forward'
    Description

    The place of the element to click to.

  • Name
    options.clickCount
    Type
    number
    Description

    The number of times to click the element.

{
    "action": "click",
    "selector": "#targetButtonId",
    "options": {
        "delay": 1000,
        "selector": "#targetButtonId",
        "button": "middle",
        "clickCount": 1,
    }
}

Scroll Horizontally

Scrolls within the target element along the x-axis.

Action Parameters

  • Name
    selector
    Type
    string
    Description

    The selector of the HTML element to scroll within.

  • Name
    value
    Type
    number
    Description

    The distance, in pixels, to scroll along the x-axis.

{
    "action": "scroll_x",
    "selector": "#targetElementId",
    "value": 1000
}

Scroll Vertically

Scrolls within the target element along the y-axis.

Action Parameters

  • Name
    selector
    Type
    string
    Description

    The selector of the HTML element to scroll within.

  • Name
    value
    Type
    number
    Description

    The distance, in pixels, to scroll along the y-axis.

{
    "action": "scroll_y",
    "selector": "#targetElementId",
    "value": 1000
}

Type

Types the given value into the target HTML element.

Action Parameters

  • Name
    selector
    Type
    string
    Description

    The selector of the HTML element to type into.

  • Name
    value
    Type
    string
    Description

    The value to type.

  • Name
    options.delay
    Type
    number
    Description

    The number of milliseconds to wait between each keyboard stroke.

{
    "action": "type",
    "selector": "#targetElementId",
    "value": "valueToType",
    "options": {
        "delay": 250,
    }
}

Get Items in the List

Scrolls on a list and gets the HTML items.

Action Parameters

  • Name
    scrollDelay
    Type
    number
    Description

    The amount of time, in milliseconds, to wait between each scroll.

  • Name
    options.list_selector
    Type
    string
    Description

    The selector of the list to scroll on.

  • Name
    options.items_selector
    Type
    string
    Description

    The selector of the HTML items to get.

  • Name
    options.num_of_items
    Type
    number
    Description

    The number of items to get.

{
    "action": "scroll_on_list_and_get_items",
    "scrollDelay": 500,
    "options": {
        "list_selector": "#targetListId",
        "items_selector": "#targetItemId",
        "num_of_items": 25,
    }
}

Solve Slider Captcha

Solves a slider captcha.

Action Parameters

  • Name
    options.slider_selector
    Type
    string
    Description

    The selector of the slider.

  • Name
    options.slider_btn_selector
    Type
    string
    Description

    The selector of the slider button.

{
    "action": "slider_captcha",
    "options": {
        "slider_selector": "#targetSliderId",
        "slider_btn_selector": "#targetSliderBtnId",
    }
}

Evaluate

Runs a function within the target page.

Action Parameters

  • Name
    value
    Type
    string
    Description

    A string containing the function to run.

{
    "action": "evaluate",
    "value": "console.log('bar')"
}