JS Actions
Perform User Interactions such as Type, Wait, Click, Evaluate JS Script, Scroll, Scroll_till_end and more using "actions" parameter in GetOData Request.
The JS actions should be in proper format and encoded and so we recommend using our API Dashboard to create the accurate code for the request.
For Example: To Perform a Type action in your request:
- Python
- JavaScript
- curl
import requests
params = {
'apiKey': '5297e11d91b6647eb47f76c5',
'url': 'https://myexternalip.com/raw',
'location': 'Auto',
'js_enabled': 'Yes',
'antibot_level': '1',
'actions':"""[
{"action": "type", "xpath":"xpath_of_element_to_type" }
]"""
}
url = 'https://api.getodata.com/'
response = requests.get(url, params=params)
responseData = response.json()
print(responseData)
const params = {
apiKey: "5297e11d91b6647eb47f76c5",
url: "https://myexternalip.com/raw",
location: "Auto",
js_enabled: "Yes",
antibot_level: "1",
actions: `[
{"action": "type", "xpath":"xpath_of_element_to_type" }
]`,
};
const url = "https://api.getodata.com/";
const queryString = new URLSearchParams(params).toString();
const fullUrl = `${url}?${queryString}`;
fetch(fullUrl)
.then((response) => response.json())
.then((responseData) => console.log(responseData))
.catch((error) => console.error("Error:", error));
6c5&url=https://myexternalip.com/raw&location=Auto&js_enable
d=Yes&antibot_level=1&actions=%5B%7B%22action%22%3A%22type%2
2%2C%22xpath%22%3A%22xpath_of_element_to_type%22%7D%5D"
Note
: Make sure the key and value pair are surrounded by double quotes and not single quotes to prevent format error. Xpath values can have single quotes. Also last action should not have a "," after ending. This causes internal server error.
Here are the example of all the actions you can perform in any request:
actions = [
{"action": "type", "value": "Text To Add", "xpath":"//xpath_of_element_to_type"},
{"action": "wait", "value": 5},
{"action": "click", "xpath":"//xpath_of_element_to_click"},
{"evaluate": "evaluate", "value": "js_script_to_run_on_page"},
{"action": "scroll_till_end"},
{"action": "scroll", "top": 400}
]
For any Questions, feel free to contact customer support through bottom right chat option on Homepage.