Skip to main content

Fast HTML5 CSS selector.

Project description

https://img.shields.io/pypi/v/selectolax.svg https://img.shields.io/travis/rushter/selectolax.svg

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

License

Project details


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.9.tar.gz (1.3 MB view details)

Uploaded Source

Built Distribution

selectolax-0.1.9-cp36-cp36m-macosx_10_7_x86_64.whl (663.2 kB view details)

Uploaded CPython 3.6mmacOS 10.7+ x86-64

File details

Details for the file selectolax-0.1.9.tar.gz.

File metadata

  • Download URL: selectolax-0.1.9.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.6

File hashes

Hashes for selectolax-0.1.9.tar.gz
Algorithm Hash digest
SHA256 e4f59c0dd010f30e98fdd844a7e58afb7dc4ec90d26a1158586d3849cc1cd9d0
MD5 3b6beeb47f5f5233fd68099fb7c84eb9
BLAKE2b-256 159ebd1c5444c6a1944eb9fa02fc7334d5e84e298cb51898ecd3819cae3d6cb0

See more details on using hashes here.

File details

Details for the file selectolax-0.1.9-cp36-cp36m-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for selectolax-0.1.9-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 7cf3e263c97fa1f84ae11c3e71c7bbce5eba5e32203553234c878e635770c01d
MD5 f5f03debd3c9d9f37746c3bff2c2af8d
BLAKE2b-256 0c1c1466a96924f3f7edb3ef57a6dc524b11db98cb3616292d222dbbfd00a5ae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page