debian-python-cssselect2/docs/index.rst

42 lines
1.0 KiB
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

.. include:: ../README.rst
Installation
============
Installing cssselect2 with pip_ should Just Work::
pip install cssselect2
This will also automatically install cssselect2s only dependency, tinycss2_.
cssselect2 and tinycss2 both only contain Python code and should work on any
Python implementation, although theyre only tested on CPython.
.. _pip: http://pip-installer.org/
.. _tinycss2: http://tinycss2.readthedocs.io/
Basic Example
=============
Here is a classical cssselect2 workflow:
- parse a CSS stylesheet using tinycss2_,
- store the CSS rules in a :meth:`~cssselect2.Matcher` object,
- parse an HTML document using an ElementTree-like parser,
- wrap the HTML tree in a :meth:`~cssselect2.ElementWrapper` object,
- find the CSS rules matching each HTML tag, using the matcher and the wrapper.
.. literalinclude:: ../example.py
.. module:: cssselect2
.. autoclass:: Matcher
:members:
.. autofunction:: compile_selector_list
.. autoclass:: ElementWrapper
:members:
.. autoclass:: SelectorError
.. include:: ../CHANGES