The Advanced Web Scraper API includes a screenshot capability that allows you to automatically capture screenshots during navigation steps. This feature is particularly useful for debugging, monitoring, and verifying the navigation process.
The screenshot feature captures full-page screenshots at key points during the navigation process:
Screenshots are saved to a specified directory with filenames that include the step index, step type, and timestamp, making it easy to track the navigation flow visually.
To enable screenshots in your navigation requests, include the following options in your request:
{
"startUrl": "https://example.com",
"steps": [
// Your navigation steps here
],
"options": {
"screenshots": true,
"screenshotsPath": "./screenshots" // Optional, defaults to "./screenshots"
}
}
| Option | Type | Default | Description |
|---|---|---|---|
screenshots |
boolean | false |
Enable or disable screenshot capture |
screenshotsPath |
string | "./screenshots" |
Directory where screenshots will be saved |
{
"startUrl": "https://example.com/login",
"steps": [
{
"type": "input",
"selector": "#username",
"value": "testuser",
"description": "Enter username"
},
{
"type": "input",
"selector": "#password",
"value": "password123",
"description": "Enter password"
},
{
"type": "click",
"selector": "#login-button",
"waitFor": ".dashboard",
"description": "Click login button"
}
],
"options": {
"screenshots": true
}
}
This configuration will capture 6 screenshots:
{
"startUrl": "https://example.com/products",
"steps": [
{
"type": "click",
"selector": ".product-category",
"waitFor": ".product-list",
"description": "Click on a product category"
},
{
"type": "extract",
"name": "products",
"selector": ".product-item",
"multiple": true,
"fields": {
"name": ".product-name",
"price": ".product-price"
},
"description": "Extract product information"
}
],
"options": {
"screenshots": true,
"screenshotsPath": "./screenshots/product-extraction"
}
}
This configuration will save screenshots to the ./screenshots/product-extraction directory.
{
"startUrl": "https://example.com/login",
"steps": [
{
"type": "input",
"selector": "#username",
"value": "testuser",
"description": "Enter username"
},
{
"type": "input",
"selector": "#password",
"value": "password123",
"description": "Enter password"
},
{
"type": "click",
"selector": "#login-button",
"description": "Click login button"
},
{
"type": "wait",
"value": ".dashboard, .captcha-container",
"description": "Wait for either dashboard or CAPTCHA"
}
],
"options": {
"screenshots": true,
"solveCaptcha": true
}
}
This configuration will capture screenshots before and after each step, including when a CAPTCHA appears and after it’s solved.
The screenshot paths are included in the navigation result response:
{
"success": true,
"message": "Navigation flow executed successfully",
"data": {
"id": "nav_1234567890",
"startUrl": "https://example.com/login",
"status": "completed",
"stepsExecuted": 3,
"result": {
// Extracted data
},
"screenshots": [
"./screenshots/0_before_input_1234567890.png",
"./screenshots/0_after_input_1234567890.png",
"./screenshots/1_before_input_1234567890.png",
"./screenshots/1_after_input_1234567890.png",
"./screenshots/2_before_click_1234567890.png",
"./screenshots/2_after_click_1234567890.png"
],
"timestamp": "2025-04-06T12:34:56.789Z"
}
}
screenshots option is set to true.When troubleshooting navigation issues:
"screenshots": true