Skip to main content
Pass an instructions array to automate browser actions before the page is returned. Instructions run in order and each one occupies the thread until it completes or times out.
The total timeout across all instructions cannot exceed 50 seconds.

Available actions

Clicks an element using JavaScript. Use this for most buttons and links.
curl -X POST https://api.scrapely.io/v2/tasks/create \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY" \
  -d '{
    "crawler": {
      "websiteURL": "https://example.com",
      "return_page_source": true,
      "instructions": [
        {
          "action": "click",
          "selector": "button[type=submit]",
          "timeout": 5
        }
      ]
    }
  }'
FieldTypeRequiredDefaultDescription
actionstringYesMust be "click".
selectorstringNo*CSS selector of the element.
xpathstringNo*XPath of the element.
timeoutnumberNo5Max wait time in seconds. Max 30.
indexintegerNo0Element index when using xpath and multiple matches exist.
You must provide either selector or xpath, not both.

Full example

Login flow using multiple instructions:
curl -X POST https://api.scrapely.io/v2/tasks/create \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY" \
  -d '{
    "crawler": {
      "websiteURL": "https://example.com/login",
      "return_page_source": true,
      "instructions": [
        { "action": "send_keys", "selector": "input#email", "text": "user@example.com" },
        { "action": "send_keys", "selector": "input#password", "text": "password123" },
        { "action": "click", "selector": "button[type=submit]" },
        { "action": "wait", "timeout": 3 }
      ]
    }
  }'