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 10 experiments to parse and retrieve URLs from 800 Google SERP pages.
Package |
Time |
Memory (peak) |
---|---|---|
selectolax |
2.38 sec. |
768.11 MB |
lxml |
18.67 sec. |
769.21 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.11.tar.gz
(1.3 MB
view hashes)
Built Distributions
Close
Hashes for selectolax-0.1.11-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5077ecc34c1698c5ad8ad8b6b6f2e2832f5037feda1726101943b70623b0ad3 |
|
MD5 | 68f091c76e15b97b34e1381df7cd591c |
|
BLAKE2b-256 | 60ce5774003d8ba2bc87222dd15ae42a10d80d53566b05f834d5981de7beec93 |
Close
Hashes for selectolax-0.1.11-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42bd6d7511e506d3a6bb96f691c7b05dfc338bb6a52c7d5e62b78548efc9935d |
|
MD5 | 560fce076f86c37d786b3711d0eff30f |
|
BLAKE2b-256 | 0b36ba97d7c27027cdb0d0d41f551c96857d17ebb980a2c9909b9408b954bd9b |