n8n – Headless Browser Automation

Using Browserless with n8n for web text & screenshots.

n8n has many great functions, but one it lacks is direct interaction with websites. To solve this, you can run Browserless in a separate container alongside n8n.

Docker Compose service

services:
  browserless:
    image: browserless/chrome:latest
    ports:
      - "3050:3000"
    environment:
      - ENABLE_DEBUGGER=false
      - PREBOOT_CHROME=true
      - MAX_CONCURRENT_SESSIONS=10
    restart: always

Text extraction with Browserless

HTTP Request node

  • Method: POST
  • URL: http://browserless:3000/function
  • Response Format: JSON
  • Body (JSON):
{
  "code": "module.exports = async ({ page }) => {
    await page.goto('https://ambientnode.uk', { waitUntil: 'domcontentloaded' });
    const bodyText = await page.evaluate(() => document.body.innerText);
    return { data: { bodyText }, type: 'application/json' };
  }"
}

Screenshot with Browserless

A simple screenshot call:

HTTP Request node

  • Method: POST
  • URL: http://browserless:3000/screenshot
  • Response Format: File
  • Body (JSON):
{
  "url": "https://ambientnode.uk",
  "options": {
    "type": "png",
    "fullPage": true
  }
}

This will give you back a PNG of the requested page.