Fast HTML5 CSS selector.
Project description
A fast HTML5 parser and CSS selectors using Modest engine.
Alpha version.
Installation
From PyPI using pip:
pip install selectolax
Development version from github:
git clone --recursive https://github.com/rushter/selectolax
cd selectolax
pip -r requirements_dev.txt
python setup.py install
Examples
from selectolax.parser import HTMLParser
html = "<div><p id=p1><p id=p2><p id=p3><a>link</a><p id=p4><p id=p5>text<p id=p6></div>"
selector = "div > :nth-child(2n+1):not(:has(a))"
for node in HTMLParser(html).css(selector):
print(node.attributes, node.text(), node.tag)
print(node.parent.tag)
print(node.html)
Simple Benchmark
Average of 5 experiments to parse and retrieve urls from 1000 Google SERP pages.
Package |
Time |
Memory (peak) |
---|---|---|
selectolax |
2.33 sec. |
20.3 MB |
lxml |
19.01 sec. |
18.5 MB |
Links
License
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
selectolax-0.1.4.tar.gz
(1.2 MB
view hashes)
Built Distribution
Close
Hashes for selectolax-0.1.4-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f440c3c6ae52f2ad930f6b301feb7c404a39a4068d5f788bad42049efdc750f0 |
|
MD5 | 81fa00b1cfee964ec44d9a157d0a2f1a |
|
BLAKE2b-256 | 018a3a442aacfe7e0ba798bc76b526157f776c21db3c3dc42b478c7d9f1c83f7 |