Cloudflare Turnstile Bypass for Automated Web Scraping - n8n Workflow

Use this sophisticated n8n workflow to automatically bypass Cloudflare Turnstile challenges using the 2Captcha service, enabling reliable data extraction and automating difficult scraping tasks.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Data Engineers and Analysts needing to scrape data from websites protected by modern anti-bot measures.
Users looking for advanced n8n templates for handling complex security challenges.
Developers seeking a reliable method to integrate captcha-solving services like 2Captcha into an n8n workflow.
Anyone building a persistent web scraping n8n automation.

Overview

Modern web scraping often hits a wall when encountering anti-bot protections like Cloudflare Turnstile. These challenges halt automated processes unless a valid solution token is provided. This specialized n8n workflow is designed to overcome this exact problem.

This automation utilizes a two-part approach:


  1. The Solver Sub-Workflow: A dedicated n8n workflow handles the entire interaction with 2Captcha, including extracting the necessary site key, requesting a solution, and robustly polling the API until the captcha is solved, providing the crucial token.

  2. The Scraper (Puppeteer): Once the token is retrieved, the main n8n workflow passes it to a Puppeteer n8n node, which performs the final, successful data extraction.

This robust n8n template ensures your automated tasks run smoothly, transforming frustrating scraping blocks into manageable steps within your larger data pipeline.

How it Works

This highly modular n8n workflow is structured using an 'Execute Workflow' n8n node to separate the core logic.

Main Execution Chain


  1. Manual Trigger: The n8n trigger starts the process (often used for testing or scheduled runs).

  2. Execute Captcha Solver: The workflow calls a secondary workflow dedicated to obtaining the Cloudflare Turnstile token using 2Captcha.

  3. Final Scrape: Once the token is returned by the secondary workflow, the Puppeteer n8n node executes the final web scraping operation, bypassing the now-resolved Turnstile challenge.

Captcha Solver Sub-Workflow (The core n8n automation)


  1. Define Target: An n8n node sets the destination_url variable.

  2. Initial Request: An HTTP Request n8n node attempts to access the page, resulting in the Turnstile challenge HTML.

  3. Sitekey Extraction: A Code n8n node parses the HTML response body to locate and extract the specific Cloudflare site key.

  4. Create Task: A second HTTP Request n8n node sends the site key and URL to the 2Captcha API to start the solving process.

  5. Polling Loop: The flow enters a loop sequence:

a. Wait 30 seconds: A Wait n8n node pauses execution, giving 2Captcha time to solve the task.
b. Check Solution Status: An HTTP Request n8n node polls the 2Captcha API for the result using the task ID.
c. Decision: A Switch n8n node checks the status (ready or pending). If ready, the workflow returns the token; if pending, it cycles back to the Wait n8n node via the 'No operation - return loop' node. If the status indicates an error or timeout, the process stops using the 'Raise runIndex error' n8n node.

Installation Guide

To deploy this powerful n8n workflow, follow these steps:


  1. Import: Copy the provided JSON data and import it into your n8n instance via the 'New' menu and 'Import from JSON'.

  2. 2Captcha Credentials: You must set up a credential for 2Captcha (or configure the API key directly within the 'Create Captcha Task' and 'Get Captcha Solution' HTTP Request n8n nodes).

  3. Puppeteer Setup: Ensure your n8n environment (especially Docker setups) is configured to support the Puppeteer n8n node, which often requires specific dependencies.

  4. URL Configuration: In the 'Set destination_url value' n8n node, update the URL parameter to the specific website you intend to scrape.

  5. Execution: Test the n8n workflow by clicking the 'Test workflow' button in the 'When clicking ‘Test workflow’ n8n trigger. Once confirmed operational, activate the entire n8n automation.

Node Details

This n8n workflow relies on a mix of core and specialized nodes:

Manual Trigger / Execute Workflow Trigger: These n8n triggers start the respective chains. The Manual Trigger starts the main chain, which executes the secondary solving workflow via the Execute Workflow n8n node.
Set (Set destination_url value): A fundamental n8n node used to define environment variables, specifically the target URL, making the n8n workflow easily configurable.
HTTP Request (Get destination web page): Fetches the initial HTML of the protected page. Crucial for obtaining the site key.
Code (Extract Turnstile Sitekey): Uses custom JavaScript within this n8n node to regex or parse the HTML to find the unique Cloudflare Turnstile site key, a required parameter for 2Captcha.
HTTP Request (Create Captcha Task / Get Captcha Solution): These two HTTP Request n8n nodes handle the interaction with the 2Captcha API—creating the task and then repeatedly checking for the solution.
Wait (Wait 30 seconds): Essential for the polling loop, this n8n node introduces necessary delays to wait for the external service to complete its operation.
Switch (Check Captcha Status): A core flow control n8n node that decides whether the process needs to loop back (pending), succeed, or stop (error).
No Operation (No operation - return loop): Used specifically to route the flow back to the start of the polling loop when the captcha is still pending.


  • Puppeteer: The final action n8n node responsible for navigating to the target site, injecting the retrieved token, and performing the final scraping task.

Related n8n Workflows

Paid

Nodes: 12 Nodes
Updated: December 26 2025
View all
Created by

If you have any questions about any of the templates I've built, please reach out to me on LinkedIn (https://www.linkedin.com/in/ludwiggerdes) or via my website down below. 👇

Featured*