How to Use Headless Chrome to Backup a Website Protected by Cloudflare WAF

Disclaimer: This article is for educational purposes only and should not be used for any malicious activity. We do not promote or condone any unauthorized access or use of websites or web scraping.

Backing up a website is crucial to ensure that you have a copy of your website's data and content, in case of an emergency. However, if your website is protected by a Web Application Firewall (WAF) such as Cloudflare, backing up the website can become a bit more challenging. In this article, we'll explain how to use Headless Chrome to backup a website protected by Cloudflare WAF.

What is Headless Chrome?

Headless Chrome is a version of the Google Chrome browser that runs in the command line, without the need for a graphical user interface. It allows developers to run automated tests, scrape websites, and perform other tasks without having to open the Chrome browser.

What is Cloudflare WAF?

Cloudflare WAF (Web Application Firewall) is a cloud-based security solution that protects websites from various security threats such as cross-site scripting (XSS), SQL injection, and other common web attacks. It acts as a barrier between your website and the internet, filtering out malicious traffic before it reaches your website.

Why Use Headless Chrome to Backup a Website Protected by Cloudflare WAF?

Headless Chrome can bypass Cloudflare WAF by sending a request to the website as if it's a regular browser request. This means that the WAF will not block the request and the website's content will be accessible to Headless Chrome. This makes it possible to backup a website protected by Cloudflare WAF.

How to Use Headless Chrome to Backup a Website Protected by Cloudflare WAF

Here's how to use Headless Chrome to backup a website protected by Cloudflare WAF. For this example, we'll be using the website as an example.

Step 1: Install the necessary packages

To use Headless Chrome in JavaScript, you'll need to install two packages: "puppeteer" and "fs". "puppeteer" is a Node.js library that provides a high-level API to control headless Chrome. "fs" is a built-in module in Node.js that provides an API for interacting with the file system.

To install the packages, run the following command in your terminal:

npm install puppeteer fs

Step 2: Create a new JavaScript file

Create a new JavaScript file, for example, "backup.js". In this file, we'll write the code to backup the website using Headless Chrome.

Step 3: Load the necessary packages

In the "backup.js" file, load the "puppeteer" and "fs" packages as follows:

const puppeteer = require('puppeteer');
const fs = require('fs');

Step 4: Define the URL of the website

In the "backup.js" file, define the URL of the website you want to backup as follows:

const url = '';

Step 5: Use the savePage() function to save the website's data

We will use the savePage() function provided by Puppeteer to save the website's data. Here's an example of how to use this function in your JavaScript code:

const savePage = async (page) => {
  await page.goto(url, { waitUntil: "networkidle2" });
  await page.waitFor(3000);
  await page.evaluate(() => { = "white";
  await page.pdf({
    path: "",
    format: "A4",
    printBackground: true,
  await browser.close();

(async () => {
  const browser = await puppeteer.launch({
    headless: false,
  const page = await browser.newPage();

In the code above, we first navigate to the URL using the page.goto() function. Then, we wait for the website to load using the page.waitFor() function. After that, we change the background color of the page to white using the page.evaluate() function. Finally, we save the page as a PDF using the page.pdf() function. The path parameter specifies the name of the file, in this case, "". The format parameter specifies the size of the paper, in this case, "A4". And the printBackground parameter specifies whether to print the background, in this case, true.

Step 6: Run the code and verify the backup

Now that we have completed the code, we can run it using Node.js. To do this, open a terminal, navigate to the directory where the code is saved, and run the following command:

node index.js

After the code has completed running, you should see a new file named "" in the same directory. Open the file and verify that it contains the content of the website. If everything is as expected, you have successfully backed up the website using Headless Chrome and Puppeteer.

Please note that this is just one way to back up a website. There are many other methods and tools available, each with its own strengths and weaknesses. This method should be used with caution and only for legal and ethical purposes.

In conclusion, by using Headless Chrome and Puppeteer, we can automate the process of backing up a website and bypassing any Cloudflare WAF protection. With a little bit of coding and a lot of caution, you can create your own backup solution that suits your needs.