Alters css selector names across css files and html templates.
Project description
LiquidCSS
Python package for altering CSS selector names across multiple files.
Description & Implementation
The package offers up a way to counteract targeted scraping by changing all CSS selector names across multiple files to unique identifiers.
Install the package with: pip install liquidcss
https://pypi.org/project/liquidcss/
Usage
Create a python file of any name and place it in your working directory. For the sake of this example we will call the file liquify.py
. The liquidcss
package offers one main function rename_selectors
. The function takes in a list of paths to the CSS files, a list of paths to the HTML files and a list of paths to JavaScript files. \
The JavaScript file must containe exclusively var
and const
declarations and the selector prefix (either .
or #
). Please refer to the example folder for demonstration. The idea is to export all selector names to their own files and assign them to variables.
Contents of liquify.py
file.
import liquidcss
liquidcss.rename_selectors(
css_files = ['example/original/css/sample001.css', ],
html_files = ['example/original/html/sample001.html', ],
js_files = ['example/original/js/sample001.js', ],
)
Execute the file with python liquify.py
The function will create a directory structure with the base folder liquidcss_
inside the directory where the liquify.py
file is located. Inside the directory structure the function will place copies of the specified CSS JavaScript and HTML files with substituted selector names. The mapping.json
file will include all substitution relationships.
Important: The resulting folder structure maybe different from the original one, so HTML files' references to JavaScript and CSS files may be broken in the process.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for liquidcss-0.3.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f042880cdc79c6f067e4f9c13ac9319f2939015c8d89d9edcb07cadae658e8a |
|
MD5 | a1de6342ca7348ad13dc9272f94ccac5 |
|
BLAKE2b-256 | db00baa8df0ac9c72443f01e74034fcddc2d5a8dbbde2a0d6c9e1dee43dda26e |