Actions5
JSON → Scrape
AI-generatedOverview
This node integrates with the Browserless API to perform various browser automation tasks such as scraping JSON data, capturing screenshots, generating PDFs, rendering content, and executing custom JavaScript functions in a headless browser environment. It is particularly useful for workflows that require automated web data extraction, visual content capture, or running scripts on web pages without manual intervention.
Common scenarios include:
- Extracting structured data from web pages by specifying CSS selectors.
- Taking screenshots of web pages for monitoring or reporting.
- Generating PDFs of web content for archiving or sharing.
- Running custom JavaScript code within the context of a webpage.
- Rendering page content for further processing.
For example, you can scrape product details from an e-commerce site by providing selectors for product names and prices, or capture a screenshot of a dynamically generated dashboard.
Properties
| Name | Meaning |
|---|---|
| URL | The target web page URL to visit. |
| Elements | A collection of elements to scrape, each defined by a CSS selector and an optional timeout. |
| Flattened Output | Whether to flatten the scraped JSON output into a simpler structure (true/false). |
| Browser Options | Various options to configure the browser behavior: - BlockAds: Block advertisement network traffic. - Headless: Run browser in headless mode. - Ignore HTTPS Errors: Ignore HTTPS errors. - Stealth: Enable stealth mode to avoid bot detection. - User Data Dir: Path to reuse session data. - TrackingId: Arbitrary tracking ID. - Keep Alive: Time in milliseconds to keep browser running after session. - Flags: Command-line flags passed to Chrome. |
| Additional Options | Extra settings including: - Http Headers: Custom HTTP headers to send. - Inject Script: Scripts to inject into the page. - Inject Style: Stylesheets to inject. - Authentication: Basic HTTP auth credentials. - Cookies: HTTP cookies to add. - Goto Options: Navigation options like timeout and waitUntil. - Reject Request Pattern: Patterns of requests to block. - Reject Resource Types: Types of resources to block (e.g., images, scripts). - Request Interceptors: Modify outgoing requests. - userAgent: Custom user agent string. - Wait For: Selector or event to wait for. - Set JavaScript Enabled: Enable or disable JavaScript. - Viewport: Screen size and device emulation settings. |
Output
The node outputs data depending on the selected resource:
- JSON Scrape: Outputs scraped data as JSON objects. If "Flattened Output" is enabled, the data is simplified into a flat structure; otherwise, it retains nested structure.
- Content: Returns raw content data from the visited URL.
- Screenshot: Outputs binary image data representing the captured screenshot.
- PDF: Outputs binary PDF data of the rendered page.
- Function: Outputs the result of executed custom JavaScript code as JSON.
Binary outputs (screenshot, PDF) are provided in the binary.data field, while JSON results are in the json field.
Dependencies
- Requires access to the Browserless API service.
- Needs an API key credential configured in n8n for authentication with Browserless.
- Network access to the target URLs.
- Optional: Configuration of browser options and additional HTTP request parameters.
Troubleshooting
Common issues:
- Invalid or missing URL parameter will cause failures.
- Incorrect CSS selectors may result in empty or incomplete scraped data.
- Network errors or blocked requests due to firewall or CORS policies.
- API authentication errors if the API key is invalid or missing.
- Timeout errors if page load or element wait times are too short.
Error messages:
"Request failed"or"Network error": Check URL accessibility and internet connection."Authentication failed": Verify API key credential configuration."Element not found": Confirm correctness of CSS selectors and increase timeout if needed."Timeout exceeded": Increase timeout values in browser or navigation options.
Resolving these usually involves verifying input parameters, ensuring valid credentials, and adjusting timeouts or selectors.
Links and References
- Browserless API Documentation
- Chromium Command Line Switches
- Puppeteer API (Browser Automation) (Browserless uses Puppeteer under the hood)