Quick overview
This sub-workflow is triggered by other n8n workflows to scrape a URL via Bright Data Web Unlocker, serving results from an n8n Data Table cache when fresh and returning a consistent response object with status, content, and error details.
How it works
- Triggers when another n8n workflow calls it as a sub-workflow and passes a URL plus optional format and max-age settings.
- Validates the URL, normalizes the requested output format, and calculates the cache freshness window.
- Checks an n8n Data Table cache for the exact URL and returns cached content immediately if it is present and still fresh.
- On a cache miss, requests the page from Bright Data and inspects the body to detect Bright Data error envelopes, empty responses, or unusually thin content.
- If the first fetch looks empty or too thin, retries the same Bright Data request with browser rendering enabled to handle JavaScript-heavy pages.
- Returns a standardized result (including ok, from_cache, rendered, bytes, content, and error) and upserts the latest response into the Data Table for future calls.
Setup
- Create a Bright Data Web Unlocker zone and add an HTTP Header Auth credential in n8n for the Bright Data API.
- Create an n8n Data Table named scrape_cache with at least url, status, content, and fetched_at columns.
- Update the default unlocker zone name and any default values (format and max_age_minutes) in the workflow settings as needed.
- In your calling workflow, use Execute Sub-workflow to run this workflow and pass url (and optionally format and max_age_minutes).