Actions
When making a Browser Request, you can specify a list of actions you want us to perform on the requested web page. These actions conform to the following format:
{
"type": "", //the type of the action
//other params follow as key-value pairs
"key": value //string, number, etc.
}Universal Parameters
All actions have the following parameters:
type
string
The type name of the action.
continue_on_fail
boolean
Should execution of further actions continue or throw an error if this action fails.
Default: false
custom_id
string
A custom_id to help you find the action in the response.
Default: null
Action Execution
Actions are carried out in the order they are submitted. Every action type has a continue_on_fail parameter, which defaults to false.This means that if any action fails, the execution of the browser request ends, and an error will be returned. Setting continue_on_fail to true ensures that all actions are carried out, regardless of the previous action's results, and an error will not be returned.
Custom Id
As shown above, you can submit a custom_id with each action you submit to the API. We'll include this ID in the outputs from the browser request so you can find a certain action's output and/or status easily in the response.
Response Format
When a browser request has completed, information on an action's execution
Choosing an action
I want to…
Use
Not
Find selectors on a page I don't know
generate_markdown — it drops the structure you need
Work out why a selector isn't matching
generate_simplified_dom — it may have removed what you're looking for
Turn one HTML table into rows
parse_json — you'd pay credits for something free, and it wouldn’t be deterministic
Pull structured data out of prose, a PDF, or a messy layout
parse_table — it only reads <table> markup
Keep a copy of a page I can look at again later
capture_screenshot — you can't search an image
Get a file the browser has open
print — it re-renders the page instead of taking the file
Capture several pages of results in one request
Sending one request per page — you'd pay the page load each time |
Supported Actions
The Gaffa API supports the following actions, detailed below. Click the "read more" buttons to read more information about each type.
Actions without outputs
block_dom_removals
Prevents the page from removing elements from the DOM.
scroll
Scroll to a particular point on the page or, in the case of pages with infinite scrolling, scroll until a given time has elapsed.
wait
Wait for a given time to elapse or an element to appear on page before proceeding to the next action.
Actions with outputs
capture_cookies
Save a JSON object of cookies for the current page
capture_element
Export the contents of a single element on the page
capture_snapshot
Create a completely static version of the web page which can be accessed offline
generate_simplified_dom
Generate a simplified version of the DOM
Flow Actions
loop
Runs nested actions repeatedly until it reaches a limit, times out, or an action fails.
Last updated