Skip to content
Converts css to json and vice versa
Python Makefile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cssjson
tests
.bumpversion.cfg
LICENSE
MANIFEST.in
Makefile
README.md
dev_requirements.txt
example.css
examples.py
requirements.txt
setup.cfg
setup.py

README.md

CSSJSON 🚀

A Python scripts that converts css to json. I usually use this when I do web scrapping and I need to scrape something from css using classnames or ids.

Installation

GitHub

$ git clone https://github.com/CITGuru/cssjson.git
$ cd cssjson
$ python setup.py install

PyPI

$ pip install cssjson

Usage

from cssjson import toJSON, toCSS

json = toJSON("example.css", path=True)
print(json)
css = toCSS(json)
print(css)

Methods

toJSON (text, path, url)

Converts css to json and can either be a text, file or url.

Text

print(toJSON(".a{background:yellow}")

Path

print(toJSON("example.css", path=True)

Url

print(toJSON("https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css", url=True)

toCSS (dict)

Converts json serialized css to css.

print(toCSS({"rules":{}}))

Contribution

You can contribute by sending a PR.

Author

Oyetoke Toby (oyetoketoby80@gmail.com)

You can’t perform that action at this time.