Using Browser Commands
This example shows how to execute actions in the browser and perform any number of operations to get the website in the correct state before responding with the content.
These commands are all executed with human-like behavior such as moving the mouse to elements before taking action on them, moving the mouse randomly while waiting, variable click and typing speed etc.
Any issues trying to execute your commands will be highlighted in the errorMessages
response field.
Command | Value | Example |
---|---|---|
click / tap | CSS selector of the element to click. | { "click": "#buttonId" } |
input / fill / type | CSS selector to target and value to enter into input field. | { "input": { "input[name='email']": "example@test.com" } } |
select / choose / pick | CSS selector to target and value or text to select from the options. | { "select": { "select[name='country']": "USA" } } |
wait | Amount of time to wait in milliseconds (maximum of 15000). | { "wait": 5000 } |
waitfor / wait-for / wait_for | CSS selector of the element to wait for. | { "waitfor": "#newForm" } |
javascript / js / eval | Custom JavaScript snippet to execute against the page. | { "javascript": "console.log('hello!!')" } |
If you need assistance with CSS selectors, you should try the Rayrun browser extension to select the elements you want to interact with and let it generate the CSS selector for you.
Options for using natural language to control the browser is coming soon!
Example Request
Browser commands are not available using the GET method.
POST https://api.scrapi.tech/v1/scrape
{
"url": "https://www.roboform.com/filling-test-all-fields",
"useBrowser": true,
"acceptDialogs": "true",
"browserCommands": [
{ "input": { "input[name='01___title']": "Mr" } },
{ "input": { "input[name='02frstname']": "Werner" } },
{ "input": { "input[name='04lastname']": "van Deventer" } },
{ "select": { "select[name='40cc__type']": "Discover" } },
{ "wait": 3000 },
{ "waitfor": "input[type='reset']" },
{ "click": "input[type='reset']" },
{ "wait": 1000 },
{ "javascript": "console.log('any valid code...')" }
]
}
Testing
If you want to test this request or a variation of it, head to the Playground or the OpenAPI page.