Anti-scraping PHP Handler
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Balagan - anti scraping (HTML) PHP library

Balagan is a PHP library used to protect precious values and to prevent the scraping of your HTML content.

It generates HTML fake contents, nodes and other tricks in order to dupe any scraper.


  • Create a "Balagan" (c.f. bloody mess) on your HTML content.
  • Protect your data putting some Balagan content that doesn't mean anything around and inside the value itself.
  • Generate randomly CSS class names, new random nodes, fake and invisible html content.
  • HTML tags are replaced, CSS generated on the fly.
  • All the content that is generated is invisible from all browsers.


go to and run your debugger (Inspecting elements) to see.


$ cd yourProject
$ git clone
$ sudo chown -R www-data css-balagan/

File Structure

├── composer.json
├── composer.lock
├── css
│   └── style.php
├── css-balagan             # Balagan's generated files
│   ├── css-basics.php      # Require write/read permission for www-data
│   └── css-variables.php   # Require write/read permission for www-data
├── examples.php
├── items 
│   └── items.php           # Return php array of items
└── src
    ├── Balagan.php         # Main class
    └── BasicCss.php        # Other class


You could run examples.php on your browser, or copy-paste the example files below:

Example with a table of items

on index.php

    <meta charset="UTF-8">
    <link href="path/to/css/style.php" rel="stylesheet">


// Require main Class
require_once 'path/to/src/Balagan.php';

// Object creation
$balagan = new Balagan(true);

// Creation of the table, tr and td
$table  = $balagan->table();
$tr     = $balagan->tr();
$td     = $balagan->td();

 * 2 choices for injecting CSS:
 * - Write some CSS directly on the generateCssClass() call
 *                          OR
 * - Generate a CSS class which you will put into a "class" attribute
 * The 2 examples are shown below.
// Injecting CSS directly on the html tag creation
$th     = $balagan->th('border: 1px solid black; padding: 3px; font-size: 20px');

// Or Generating CSS Classes
$tableClass = $balagan->generateCssClass("border: 1px solid black; list-style-type: none; padding: 20px; margin: 0 auto; width: 12%;");

$tdClass    = $balagan->generateCssClass("padding: 3px; font-weight: bold; text-align: center; border: 1px solid gray;");

// Item values
$value_1 = $balagan->superTag("770$");
$value_2 = $balagan->superTag("26$");

$htmlTable = "
<h1 style='text-align: center'>Example with table, th, tr & td</h1>
        <$table class='$tableClass'>
            <$td class='$tdClass'>November</$td>
            <$td class='$tdClass'>$value_1</$td>
            <$td class='$tdClass'>December</$td>
            <$td class='$tdClass'>$value_2</$td>
echo $htmlTable;

On style.php


require_once '../path/to/src/Balagan.php';

header("Content-type: text/css; charset: UTF-8");


  • Write more HTML Tags functions and increase BasicCss Class(a, strong, ...)
  • Think about js for peoples who want to get these tags.



Free Software, Hell Yeah!