Skip to main content

Using Browserless with n8n

n8n is a powerful workflow automation platform that allows you to connect different services and automate tasks. This guide will show you how to use Browserless with n8n to automate browser-based tasks. For the templates below, remember to replace YOUR_API_TOKEN_HERE with your actual Browserless API token

n8n Workflow Example

Prerequisites

  • A Browserless account with an API token
  • An n8n instance (self-hosted or cloud)

Available Endpoints

Screenshot

The /screenshot endpoint allows you to capture screenshots of web pages. This is useful for:

  • Visual monitoring of websites
  • Creating thumbnails
  • Documenting web content

Learn more about the Screenshot API

{
"nodes": [
{
"parameters": {
"method": "POST",
"url": "https://production-sfo.browserless.io/screenshot",
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "token",
"value": "YOUR_API_TOKEN_HERE"
}
]
},
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "url",
"value": "https://www.example.com"
}
]
}
},
"type": "n8n-nodes-base.httpRequest",
"name": "Screenshot"
}
]
}

PDF Generation

The /pdf endpoint generates PDF documents from web pages. This is useful for:

  • Creating printable versions of web content
  • Archiving web pages
  • Generating reports

Learn more about the PDF API

{
"nodes": [
{
"parameters": {
"method": "POST",
"url": "https://production-sfo.browserless.io/pdf",
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "token",
"value": "YOUR_API_TOKEN_HERE"
}
]
},
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "url",
"value": "https://www.example.com"
}
]
}
},
"type": "n8n-nodes-base.httpRequest",
"name": "PDF"
}
]
}

Content Extraction

The /content endpoint extracts the HTML content from web pages. This is useful for:

  • Web scraping
  • Content analysis
  • Data extraction

Learn more about the Content API

{
"nodes": [
{
"parameters": {
"method": "POST",
"url": "https://production-sfo.browserless.io/content",
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "token",
"value": "YOUR_API_TOKEN_HERE"
}
]
},
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "url",
"value": "https://www.example.com"
}
]
}
},
"type": "n8n-nodes-base.httpRequest",
"name": "Content"
}
]
}

Unblock

The /unblock endpoint helps bypass common anti-bot measures. This is useful for:

  • Accessing protected content
  • Handling CAPTCHAs
  • Managing cookies and sessions

Learn more about the Unblock API

{
"nodes": [
{
"parameters": {
"method": "POST",
"url": "https://production-sfo.browserless.io/unblock",
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "token",
"value": "YOUR_API_TOKEN_HERE"
}
]
},
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "url",
"value": "https://www.example.com"
},
{
"name": "cookies",
"value": "true"
},
{
"name": "browserWSEndpoint",
"value": "true"
},
{
"name": "content",
"value": "true"
},
{
"name": "screenshot",
"value": "true"
}
]
}
},
"type": "n8n-nodes-base.httpRequest",
"name": "Unblock"
}
]
}

Browser Query Language (BQL)

The /chrome/bql endpoint allows you to execute complex browser automation tasks using GraphQL. This is useful for:

  • Complex form filling
  • Multi-step workflows
  • Custom browser automation

Learn more about BQL

{
"nodes": [
{
"parameters": {
"method": "POST",
"url": "https://production-sfo.browserless.io/chrome/bql",
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "token",
"value": "YOUR_API_TOKEN_HERE"
}
]
},
"sendBody": true,
"contentType": "raw",
"rawContentType": "application/json",
"body": "{\"query\": \"mutation FormExample {\\n goto(url: \\\"https://www.browserless.io/practice-form\\\") {\\n status\\n }\\n select(selector:\\\"#Contact-Subject\\\",value:\\\"support\\\"){ time } \\n typeEmail: type(text: \\\"john@email.com\\\", selector: \\\"#Email\\\") {\\n time\\n }\\n typeMessage: type(\\n selector: \\\"#Message\\\"\\n text: \\\"Hello world!\\\"\\n ) {\\n time\\n }\\n verify(\\n type: cloudflare\\n ){\\n solved\\n }\\n waitForTimeout(time:3000){time}\\n screenshot{\\n base64\\n }\\n}\", \"variables\": {}, \"operationName\": \"FormExample\"}"
},
"type": "n8n-nodes-base.httpRequest",
"name": "BQL"
}
]
}

Function

The /function endpoint allows you to execute custom JavaScript code in a browser context. This is useful for:

  • Custom browser automation
  • Complex data extraction
  • Multi-step workflows

Learn more about the Function API

{
"nodes": [
{
"parameters": {
"method": "POST",
"url": "https://production-sfo.browserless.io/function",
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "token",
"value": "YOUR_API_TOKEN_HERE"
}
]
},
"sendBody": true,
"contentType": "raw",
"rawContentType": "application/javascript",
"body": "export default async function ({ page }) {\n await page.goto(\"https://example.com/\");\n const url = await page.content();\n const buffer = await page.pdf({ format: \"A4\" });\n const base64PDF = buffer.toString('base64');\n const screenshot = await page.screenshot({ encoding: \"base64\" });\n\n return {\n data: {\n url,\n screenshot,\n base64PDF\n },\n type: \"application/json\",\n };\n}"
},
"type": "n8n-nodes-base.httpRequest",
"name": "Function"
}
]
}