Unlocking the Gate: A Guide to Bypassing Cloudflare Turnstile Captcha

Tri Firdyanto
2 min readOct 5, 2024

--

Photo by Rock'n Roll Monkey on Unsplash

When scraping a web application, mostly we face an anti-bot, the nemesis of web scrapers, which is Captcha.

For those who don’t know what Captcha is, Captcha is a test used on websites to make sure you’re a human, not a robot. It usually asks you to solve simple challenges like clicking on pictures, typing words, or checking a box that says, “I’m not a robot.”
There are so many types of Captcha on the internet, such as Google’s reCAPTCHA, or the one we will discuss today, Cloudflare Turnstile.

Usually, to bypass a Captcha, we need a third party, which often comes with a certain fee. However, in this article, I will share how to bypass Cloudflare Turnstile without paying for third-party services.
Let me introduce the tool, which is Puppeteer Real Browser.

For web scrapers, the term Puppeteer is probably familiar; to give an overview, Puppeteer is a JavaScript library that provides a high-level API to control Chrome or Firefox over the DevTools Protocol or WebDriver BiDi.
With the help of the Puppeteer Real Browser tool, we can perform scraping without worrying about how to bypass Cloudflare’s Captcha.
For more detailed information, you can visit the official GitHub page Puppeteer Real Browser.

Installation

npm i puppeteer-real-browser

If you are using a Linux operating system, xvfb must be installed for the library to work correctly.

sudo apt-get install xvfb

Usage

const { connect } = require("puppeteer-real-browser")

async function test() {
const { browser, page } = await connect({
headless: false,
args: [],
customConfig: {},
turnstile: true,
connectOption: {},
disableXvfb: false,
ignoreAllFlags: false
})
await page.goto('https://2captcha.com/demo/cloudflare-turnstile')
}

test()

Example

Here is a video of a comparison between Puppeteer and Puppeteer Real Browser:

Using Puppeteer:

Using Puppeteer

Using Puppeteer Real Browser:

--

--