Actions8
- Browser Rest Apis Actions
Overview
This node interacts with the Browserless API to capture screenshots of web pages. It is useful for automating the process of taking screenshots of websites, either full pages or specific elements, with various customization options such as viewport size, image format, quality, and more. Practical applications include website monitoring, visual testing, content archiving, and generating previews of web pages.
Use Case Examples
- Capture a full-page screenshot of a given URL in JPEG format with optimized speed.
- Take a screenshot of a specific element on a page by providing a CSS selector.
- Use custom viewport settings and emulate media types to capture screenshots as they would appear on different devices.
- Add custom scripts or styles before taking the screenshot to modify the page appearance.
Properties
| Name | Meaning |
|---|---|
| Scroll Page | Whether to scroll the page before taking the screenshot. |
| Url | The URL of the web page to capture a screenshot from. |
| Selector | CSS selector to capture a screenshot of a specific element. |
| Wait For Timeout | Time in milliseconds to wait before taking the screenshot. |
| Wait For Selector | Wait for a specific selector to appear or become visible/hidden before taking the screenshot. |
| Options | Various screenshot options such as image type, quality, full page capture, clipping region, encoding, and more. |
| Goto Options | Options for navigating to the URL such as referer, timeout, waitUntil events, and signal for cancellation. |
| Wait For Event | Wait for a specific browser event before taking the screenshot. |
| Wait For Function | Wait for a custom function to evaluate to true in the browser context before taking the screenshot. |
| Add Script Tag | Add JavaScript scripts to the page before taking the screenshot. |
| Add Style Tag | Add CSS styles to the page before taking the screenshot. |
| Set Extra HTTP Headers | Set additional HTTP headers for the page request. |
| Authenticate | Provide username and password for HTTP authentication. |
| Viewport | Set viewport properties such as width, height, device scale factor, mobile mode, landscape mode, and touch support. |
| Emulate Media Type | Emulate a specific media type for the page (e.g., screen, print). |
| Timeout | Override the system-level timeout for the request in milliseconds. |
| Html | Provide raw HTML content to render instead of loading a URL. |
| User Agent | Set a custom user agent string for the browser. |
| Best Attempt | Attempt to proceed with the screenshot even if awaited events fail or timeout. |
| Enable Cookies | Enable cookies for the session. |
| Cookies | Array of cookie objects to set in the browser session. |
| Block Ads | Enable or disable ad-blocking extensions during the session. |
| Set Java Script Enabled | Enable or disable JavaScript execution in the browser. |
| Enable Launch | Launch a new browser instance for the screenshot. |
| Launch | Options for launching the browser instance such as args, viewport, devtools, headless mode, slow motion, stealth mode, and more. |
| Reject Resource Types | Resource types to block from loading during the page load. |
| Reject Request Pattern | Patterns of requests to block during the page load. |
| Request Interceptors | Intercept and modify network requests matching specified patterns. |
| Use Custom Body | Whether to use a custom request body instead of the standard parameters. |
| Custom Body | Custom JSON body to send with the request, allowing full control over all options. |
Output
JSON
screenshot- The captured screenshot image data, encoded as specified (e.g., base64 or binary).
Dependencies
- Browserless API
Troubleshooting
- Common issues include timeouts if the page takes too long to load or if selectors/functions to wait for do not appear in time. Adjusting timeout settings or using the 'bestAttempt' option can help.
- Incorrect CSS selectors for the 'selector' property may result in empty or incorrect screenshots. Verify selectors carefully.
- If the image quality or format is not as expected, check the 'options' property settings such as 'type' and 'quality'.
- Ad-blocking may cause some sites to not load properly; disable 'blockAds' if necessary.
- Authentication failures can occur if username or password are incorrect; verify credentials if using the 'authenticate' option.
Links
- Browserless Screenshot Documentation - Official documentation for screenshot capabilities of Browserless API.