selectolax 0.3.30__cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of selectolax might be problematic. Click here for more details.
- selectolax/__init__.py +10 -0
- selectolax/base.pxi +4 -0
- selectolax/lexbor/attrs.pxi +103 -0
- selectolax/lexbor/node.pxi +879 -0
- selectolax/lexbor/selection.pxi +190 -0
- selectolax/lexbor/util.pxi +19 -0
- selectolax/lexbor.c +55465 -0
- selectolax/lexbor.cpython-311-aarch64-linux-gnu.so +0 -0
- selectolax/lexbor.pxd +580 -0
- selectolax/lexbor.pyi +177 -0
- selectolax/lexbor.pyx +357 -0
- selectolax/modest/node.pxi +987 -0
- selectolax/modest/selection.pxi +193 -0
- selectolax/modest/util.pxi +19 -0
- selectolax/parser.c +52646 -0
- selectolax/parser.cpython-311-aarch64-linux-gnu.so +0 -0
- selectolax/parser.pxd +581 -0
- selectolax/parser.pyi +323 -0
- selectolax/parser.pyx +446 -0
- selectolax/py.typed +0 -0
- selectolax/utils.pxi +107 -0
- selectolax-0.3.30.dist-info/METADATA +197 -0
- selectolax-0.3.30.dist-info/RECORD +26 -0
- selectolax-0.3.30.dist-info/WHEEL +7 -0
- selectolax-0.3.30.dist-info/licenses/LICENSE +10 -0
- selectolax-0.3.30.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: selectolax
|
|
3
|
+
Version: 0.3.30
|
|
4
|
+
Summary: Fast HTML5 parser with CSS selectors.
|
|
5
|
+
Home-page: https://github.com/rushter/selectolax
|
|
6
|
+
Author: Artem Golubin
|
|
7
|
+
Author-email: Artem Golubin <me@rushter.com>
|
|
8
|
+
License:
|
|
9
|
+
MIT License
|
|
10
|
+
|
|
11
|
+
Copyright (c) 2018-2025, Artem Golubin
|
|
12
|
+
|
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
18
|
+
|
|
19
|
+
Project-URL: Repository, https://github.com/rushter/selectolax
|
|
20
|
+
Project-URL: Documentation, https://selectolax.readthedocs.io/en/latest/parser.html
|
|
21
|
+
Project-URL: Changelog, https://github.com/rushter/selectolax/blob/main/CHANGES.rst
|
|
22
|
+
Keywords: selectolax,html,parser,css,fast
|
|
23
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
24
|
+
Classifier: Topic :: Text Processing :: Markup :: HTML
|
|
25
|
+
Classifier: Topic :: Internet
|
|
26
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
27
|
+
Classifier: Intended Audience :: Developers
|
|
28
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
29
|
+
Classifier: Natural Language :: English
|
|
30
|
+
Classifier: Programming Language :: Python :: 3
|
|
31
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
32
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
33
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
36
|
+
Requires-Python: >=3.9
|
|
37
|
+
Description-Content-Type: text/x-rst
|
|
38
|
+
License-File: LICENSE
|
|
39
|
+
Requires-Dist: Cython==3.0.11
|
|
40
|
+
Dynamic: author
|
|
41
|
+
Dynamic: home-page
|
|
42
|
+
Dynamic: license-file
|
|
43
|
+
|
|
44
|
+
.. image:: docs/logo.png
|
|
45
|
+
:alt: selectolax logo
|
|
46
|
+
|
|
47
|
+
-------------------------
|
|
48
|
+
|
|
49
|
+
.. image:: https://img.shields.io/pypi/v/selectolax.svg
|
|
50
|
+
:target: https://pypi.python.org/pypi/selectolax
|
|
51
|
+
|
|
52
|
+
A fast HTML5 parser with CSS selectors using `Modest <https://github.com/lexborisov/Modest/>`_ and
|
|
53
|
+
`Lexbor <https://github.com/lexbor/lexbor>`_ engines.
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
Installation
|
|
57
|
+
------------
|
|
58
|
+
From PyPI using pip:
|
|
59
|
+
|
|
60
|
+
.. code-block:: bash
|
|
61
|
+
|
|
62
|
+
pip install selectolax
|
|
63
|
+
|
|
64
|
+
If installation fails due to compilation errors, you may need to install `Cython <https://github.com/cython/cython>`_:
|
|
65
|
+
|
|
66
|
+
.. code-block:: bash
|
|
67
|
+
|
|
68
|
+
pip install selectolax[cython]
|
|
69
|
+
|
|
70
|
+
This usually happens when you try to install an outdated version of selectolax on a newer version of Python.
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
Development version from GitHub:
|
|
74
|
+
|
|
75
|
+
.. code-block:: bash
|
|
76
|
+
|
|
77
|
+
git clone --recursive https://github.com/rushter/selectolax
|
|
78
|
+
cd selectolax
|
|
79
|
+
pip install -r requirements_dev.txt
|
|
80
|
+
python setup.py install
|
|
81
|
+
|
|
82
|
+
How to compile selectolax while developing:
|
|
83
|
+
|
|
84
|
+
.. code-block:: bash
|
|
85
|
+
|
|
86
|
+
make clean
|
|
87
|
+
make dev
|
|
88
|
+
|
|
89
|
+
Basic examples
|
|
90
|
+
--------------
|
|
91
|
+
|
|
92
|
+
Here are some basic examples to get you started with selectolax:
|
|
93
|
+
|
|
94
|
+
Parsing HTML and extracting text:
|
|
95
|
+
|
|
96
|
+
.. code:: python
|
|
97
|
+
|
|
98
|
+
In [1]: from selectolax.parser import HTMLParser
|
|
99
|
+
...:
|
|
100
|
+
...: html = """
|
|
101
|
+
...: <h1 id="title" data-updated="20201101">Hi there</h1>
|
|
102
|
+
...: <div class="post">Lorem Ipsum is simply dummy text of the printing and typesetting industry. </div>
|
|
103
|
+
...: <div class="post">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>
|
|
104
|
+
...: """
|
|
105
|
+
...: tree = HTMLParser(html)
|
|
106
|
+
|
|
107
|
+
In [2]: tree.css_first('h1#title').text()
|
|
108
|
+
Out[2]: 'Hi there'
|
|
109
|
+
|
|
110
|
+
In [3]: tree.css_first('h1#title').attributes
|
|
111
|
+
Out[3]: {'id': 'title', 'data-updated': '20201101'}
|
|
112
|
+
|
|
113
|
+
In [4]: [node.text() for node in tree.css('.post')]
|
|
114
|
+
Out[4]:
|
|
115
|
+
['Lorem Ipsum is simply dummy text of the printing and typesetting industry. ',
|
|
116
|
+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit.']
|
|
117
|
+
|
|
118
|
+
Using advanced CSS selectors:
|
|
119
|
+
|
|
120
|
+
.. code:: python
|
|
121
|
+
|
|
122
|
+
In [1]: 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>"
|
|
123
|
+
...: selector = "div > :nth-child(2n+1):not(:has(a))"
|
|
124
|
+
|
|
125
|
+
In [2]: for node in HTMLParser(html).css(selector):
|
|
126
|
+
...: print(node.attributes, node.text(), node.tag)
|
|
127
|
+
...: print(node.parent.tag)
|
|
128
|
+
...: print(node.html)
|
|
129
|
+
...:
|
|
130
|
+
{'id': 'p1'} p
|
|
131
|
+
div
|
|
132
|
+
<p id="p1"></p>
|
|
133
|
+
{'id': 'p5'} text p
|
|
134
|
+
div
|
|
135
|
+
<p id="p5">text</p>
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
* `Detailed overview <https://github.com/rushter/selectolax/blob/master/examples/walkthrough.ipynb>`_
|
|
139
|
+
|
|
140
|
+
Available backends
|
|
141
|
+
------------------
|
|
142
|
+
|
|
143
|
+
Selectolax supports two backends: ``Modest`` and ``Lexbor``. By default, all examples use the Modest backend.
|
|
144
|
+
Most of the features between backends are almost identical, but there are still some differences.
|
|
145
|
+
|
|
146
|
+
As of 2024, the preferred backend is ``Lexbor``. The ``Modest`` backend is still available for compatibility reasons
|
|
147
|
+
and the underlying C library that selectolax uses is not maintained anymore.
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
To use ``lexbor``, just import the parser and use it in the similar way to the `HTMLParser`.
|
|
151
|
+
|
|
152
|
+
.. code:: python
|
|
153
|
+
|
|
154
|
+
In [1]: from selectolax.lexbor import LexborHTMLParser
|
|
155
|
+
|
|
156
|
+
In [2]: html = """
|
|
157
|
+
...: <title>Hi there</title>
|
|
158
|
+
...: <div id="updated">2021-08-15</div>
|
|
159
|
+
...: """
|
|
160
|
+
|
|
161
|
+
In [3]: parser = LexborHTMLParser(html)
|
|
162
|
+
In [4]: parser.root.css_first("#updated").text()
|
|
163
|
+
Out[4]: '2021-08-15'
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
Simple Benchmark
|
|
167
|
+
----------------
|
|
168
|
+
|
|
169
|
+
* Extract title, links, scripts and a meta tag from main pages of top 754 domains. See ``examples/benchmark.py`` for more information.
|
|
170
|
+
|
|
171
|
+
============================ ===========
|
|
172
|
+
Package Time
|
|
173
|
+
============================ ===========
|
|
174
|
+
Beautiful Soup (html.parser) 61.02 sec.
|
|
175
|
+
lxml / Beautiful Soup (lxml) 9.09 sec.
|
|
176
|
+
html5_parser 16.10 sec.
|
|
177
|
+
selectolax (Modest) 2.94 sec.
|
|
178
|
+
selectolax (Lexbor) 2.39 sec.
|
|
179
|
+
============================ ===========
|
|
180
|
+
|
|
181
|
+
Links
|
|
182
|
+
-----
|
|
183
|
+
|
|
184
|
+
* `selectolax API reference <http://selectolax.readthedocs.io/en/latest/parser.html>`_
|
|
185
|
+
* `Video introduction to web scraping using selectolax <https://youtu.be/HpRsfpPuUzE>`_
|
|
186
|
+
* `How to Scrape 7k Products with Python using selectolax and httpx <https://www.youtube.com/watch?v=XpGvq755J2U>`_
|
|
187
|
+
* `Detailed overview <https://github.com/rushter/selectolax/blob/master/examples/walkthrough.ipynb>`_
|
|
188
|
+
* `Modest introduction <https://lexborisov.github.io/Modest/>`_
|
|
189
|
+
* `Modest benchmark <http://lexborisov.github.io/benchmark-html-persers/>`_
|
|
190
|
+
* `Python benchmark <https://rushter.com/blog/python-fast-html-parser/>`_
|
|
191
|
+
* `Another Python benchmark <https://www.peterbe.com/plog/selectolax-or-pyquery>`_
|
|
192
|
+
|
|
193
|
+
License
|
|
194
|
+
-------
|
|
195
|
+
|
|
196
|
+
* Modest engine — `LGPL2.1 <https://github.com/lexborisov/Modest/blob/master/LICENSE>`_
|
|
197
|
+
* selectolax - `MIT <https://github.com/rushter/selectolax/blob/master/LICENSE>`_
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
selectolax/__init__.py,sha256=pIGA_AJB0k4MCry4cwB9fkmB4-NKitTuZtHbeJUlTdQ,175
|
|
2
|
+
selectolax/base.pxi,sha256=eiPKlY9gG3l49qJoRQVLl1Ljza6z1k0A-met6sDPcqE,89
|
|
3
|
+
selectolax/lexbor.c,sha256=1Uazir9DHTl3AZecgyGo-3FXckRR_8WuIWshxoVa7XM,2372840
|
|
4
|
+
selectolax/lexbor.cpython-311-aarch64-linux-gnu.so,sha256=LYZPaLUrvyhYsTNr81Xp6tf_44iCIkJ0_4bTY4zu_Gw,11602256
|
|
5
|
+
selectolax/lexbor.pxd,sha256=PwygBdb1blWAQcxXubZS5uffhgcXaqgySNMPFMT02-c,20958
|
|
6
|
+
selectolax/lexbor.pyi,sha256=1VU9C067hfUhSXWx_kXhyohqesfB7aFyA6d9CqCBxWg,6700
|
|
7
|
+
selectolax/lexbor.pyx,sha256=gwpZpx7C1NSSQUZ1yLXUP23rCJ9y1_uCRlPvFnAbhD8,11163
|
|
8
|
+
selectolax/parser.c,sha256=vnsHhHpbKUNcXKZBJMgjwOy3QNoQK_a1p-hTXi0Ol88,2236903
|
|
9
|
+
selectolax/parser.cpython-311-aarch64-linux-gnu.so,sha256=lxmY6ey_d5cp_px7Ol47ZyRFy47qsMlfasPKXVzYGOE,9496536
|
|
10
|
+
selectolax/parser.pxd,sha256=zZlg1vHUg6o4MXaiwKAo5S5hO_DqBGc4_E10qJ2EcM4,24564
|
|
11
|
+
selectolax/parser.pyi,sha256=6S9RKAevzv9zBYL1v12qQojkMst35yzy3TnD3HtZZo4,11275
|
|
12
|
+
selectolax/parser.pyx,sha256=2I0b9xWlRheISGIX2BTuA3J9XAGpB2io47Fv9L6yNvs,13541
|
|
13
|
+
selectolax/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
+
selectolax/utils.pxi,sha256=uB0-0naFQPy1JpR2DiIlKnyLyC76yWLnUHSuH11xg6s,3459
|
|
15
|
+
selectolax/lexbor/attrs.pxi,sha256=Ol2RNzXZAcWaqJdDBUe0ChOCcA8HC990Hjncj98XAkw,3138
|
|
16
|
+
selectolax/lexbor/node.pxi,sha256=4uAlILCWCwTwhC1uCsUqc4AnHQotxeiPpPrQuGkBamE,29857
|
|
17
|
+
selectolax/lexbor/selection.pxi,sha256=yS-Ke43W0yDhlU-p2JgmweO5ref6ss91R0B0ngFSppg,6761
|
|
18
|
+
selectolax/lexbor/util.pxi,sha256=Zq7S-zlyU3wOo49wGHQHnmmhpbkrcJm59ZCTPENcZQA,563
|
|
19
|
+
selectolax/modest/node.pxi,sha256=TFBo_T65BOrwXuQf_fbJ3Pw9EkeBuz_vTrmNoqY8hks,33389
|
|
20
|
+
selectolax/modest/selection.pxi,sha256=S55MMxEW2B1oPExB_DRwPM46WoWZU73J3rFRZU1URuQ,6393
|
|
21
|
+
selectolax/modest/util.pxi,sha256=aX9UnRNTITImHVBTlIs9efOd3EyugLq_Lwuo0zVTiuQ,551
|
|
22
|
+
selectolax-0.3.30.dist-info/METADATA,sha256=hJ4-50DPreLSdBEyg8bhQXgAaXOus2vbH9zq1kIZmG8,7385
|
|
23
|
+
selectolax-0.3.30.dist-info/WHEEL,sha256=nENvFvUt2sTxh7qTwFTbrHft1Jd6WkcTog-2x3-pWGY,193
|
|
24
|
+
selectolax-0.3.30.dist-info/top_level.txt,sha256=e5MuEM2PrQzoDlWetkFli9uXSlxa_ktW5jJEihhaI1c,11
|
|
25
|
+
selectolax-0.3.30.dist-info/RECORD,,
|
|
26
|
+
selectolax-0.3.30.dist-info/licenses/LICENSE,sha256=MYCcM-Cv_rC2-lQiwDumin0E-rMXAhK-qIGGA29434Y,1077
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
MIT License
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2018-2025, Artem Golubin
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
7
|
+
|
|
8
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
9
|
+
|
|
10
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
selectolax
|