selectolax 0.3.23__cp310-cp310-musllinux_1_2_x86_64.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/py.typed ADDED
File without changes
selectolax/utils.pxi ADDED
@@ -0,0 +1,13 @@
1
+ MAX_HTML_INPUT_SIZE = 250e+7
2
+
3
+ def preprocess_input(html, decode_errors='ignore'):
4
+ if isinstance(html, (str, unicode)):
5
+ bytes_html = html.encode('UTF-8', errors=decode_errors)
6
+ elif isinstance(html, bytes):
7
+ bytes_html = html
8
+ else:
9
+ raise TypeError("Expected a string, but %s found" % type(html).__name__)
10
+ html_len = len(bytes_html)
11
+ if html_len > MAX_HTML_INPUT_SIZE:
12
+ raise ValueError("The specified HTML input is too large to be processed (%d bytes)" % html_len)
13
+ return bytes_html, html_len
@@ -0,0 +1,10 @@
1
+
2
+ MIT License
3
+
4
+ Copyright (c) 2018-2023, 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,172 @@
1
+ Metadata-Version: 2.1
2
+ Name: selectolax
3
+ Version: 0.3.23
4
+ Summary: Fast HTML5 parser with CSS selectors.
5
+ Home-page: https://github.com/rushter/selectolax
6
+ Author: Artem Golubin
7
+ Author-email: me@rushter.com
8
+ License: MIT license
9
+ Project-URL: Source code, https://github.com/rushter/selectolax
10
+ Keywords: selectolax
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Topic :: Text Processing :: Markup :: HTML
13
+ Classifier: Topic :: Internet
14
+ Classifier: Topic :: Internet :: WWW/HTTP
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Natural Language :: English
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.7
20
+ Classifier: Programming Language :: Python :: 3.8
21
+ Classifier: Programming Language :: Python :: 3.9
22
+ Classifier: Programming Language :: Python :: 3.10
23
+ Classifier: Programming Language :: Python :: 3.11
24
+ Classifier: Programming Language :: Python :: 3.12
25
+ License-File: LICENSE
26
+ Provides-Extra: cython
27
+ Requires-Dist: Cython==3.0.11; extra == "cython"
28
+
29
+ .. image:: docs/logo.png
30
+ :alt: selectolax logo
31
+
32
+ -------------------------
33
+
34
+ .. image:: https://img.shields.io/pypi/v/selectolax.svg
35
+ :target: https://pypi.python.org/pypi/selectolax
36
+
37
+ A fast HTML5 parser with CSS selectors using `Modest <https://github.com/lexborisov/Modest/>`_ and
38
+ `Lexbor <https://github.com/lexbor/lexbor>`_ engines.
39
+
40
+
41
+ Installation
42
+ ------------
43
+ From PyPI using pip:
44
+
45
+ .. code-block:: bash
46
+
47
+ pip install selectolax
48
+
49
+ If installation fails due to compilation errors, you may need to install `Cython <https://github.com/cython/cython>`_:
50
+
51
+ .. code-block:: bash
52
+
53
+ pip install selectolax[cython]
54
+
55
+ This usually happens when you try to install an outdated version of selectolax on a newer version of Python.
56
+
57
+
58
+ Development version from GitHub:
59
+
60
+ .. code-block:: bash
61
+
62
+ git clone --recursive https://github.com/rushter/selectolax
63
+ cd selectolax
64
+ pip install -r requirements_dev.txt
65
+ python setup.py install
66
+
67
+ How to compile selectolax while developing:
68
+
69
+ .. code-block:: bash
70
+
71
+ make clean
72
+ make dev
73
+
74
+ Basic examples
75
+ --------------
76
+
77
+ .. code:: python
78
+
79
+ In [1]: from selectolax.parser import HTMLParser
80
+ ...:
81
+ ...: html = """
82
+ ...: <h1 id="title" data-updated="20201101">Hi there</h1>
83
+ ...: <div class="post">Lorem Ipsum is simply dummy text of the printing and typesetting industry. </div>
84
+ ...: <div class="post">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>
85
+ ...: """
86
+ ...: tree = HTMLParser(html)
87
+
88
+ In [2]: tree.css_first('h1#title').text()
89
+ Out[2]: 'Hi there'
90
+
91
+ In [3]: tree.css_first('h1#title').attributes
92
+ Out[3]: {'id': 'title', 'data-updated': '20201101'}
93
+
94
+ In [4]: [node.text() for node in tree.css('.post')]
95
+ Out[4]:
96
+ ['Lorem Ipsum is simply dummy text of the printing and typesetting industry. ',
97
+ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.']
98
+
99
+ .. code:: python
100
+
101
+ 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>"
102
+ ...: selector = "div > :nth-child(2n+1):not(:has(a))"
103
+
104
+ In [2]: for node in HTMLParser(html).css(selector):
105
+ ...: print(node.attributes, node.text(), node.tag)
106
+ ...: print(node.parent.tag)
107
+ ...: print(node.html)
108
+ ...:
109
+ {'id': 'p1'} p
110
+ div
111
+ <p id="p1"></p>
112
+ {'id': 'p5'} text p
113
+ div
114
+ <p id="p5">text</p>
115
+
116
+
117
+ * `Detailed overview <https://github.com/rushter/selectolax/blob/master/examples/walkthrough.ipynb>`_
118
+
119
+ Available backends
120
+ ------------------
121
+
122
+ Selectolax supports two backends: ``Modest`` and ``Lexbor``. By default, all examples use the Modest backend.
123
+ Most of the features between backends are almost identical, but there are still some differences.
124
+
125
+ To use ``lexbor``, just import the parser and use it in the similar way to the `HTMLParser`.
126
+
127
+ .. code:: python
128
+
129
+ In [1]: from selectolax.lexbor import LexborHTMLParser
130
+
131
+ In [2]: html = """
132
+ ...: <title>Hi there</title>
133
+ ...: <div id="updated">2021-08-15</div>
134
+ ...: """
135
+
136
+ In [3]: parser = LexborHTMLParser(html)
137
+ In [4]: parser.root.css_first("#updated").text()
138
+ Out[4]: '2021-08-15'
139
+
140
+
141
+ Simple Benchmark
142
+ ----------------
143
+
144
+ * Extract title, links, scripts and a meta tag from main pages of top 754 domains. See ``examples/benchmark.py`` for more information.
145
+
146
+ ============================ ===========
147
+ Package Time
148
+ ============================ ===========
149
+ Beautiful Soup (html.parser) 61.02 sec.
150
+ lxml 9.09 sec.
151
+ html5_parser 16.10 sec.
152
+ selectolax (Modest) 2.94 sec.
153
+ selectolax (Lexbor) 2.39 sec.
154
+ ============================ ===========
155
+
156
+ Links
157
+ -----
158
+
159
+ * `selectolax API reference <http://selectolax.readthedocs.io/en/latest/parser.html>`_
160
+ * `Video introduction to web scraping using selectolax <https://youtu.be/HpRsfpPuUzE>`_
161
+ * `How to Scrape 7k Products with Python using selectolax and httpx <https://www.youtube.com/watch?v=XpGvq755J2U>`_
162
+ * `Detailed overview <https://github.com/rushter/selectolax/blob/master/examples/walkthrough.ipynb>`_
163
+ * `Modest introduction <https://lexborisov.github.io/Modest/>`_
164
+ * `Modest benchmark <http://lexborisov.github.io/benchmark-html-persers/>`_
165
+ * `Python benchmark <https://rushter.com/blog/python-fast-html-parser/>`_
166
+ * `Another Python benchmark <https://www.peterbe.com/plog/selectolax-or-pyquery>`_
167
+
168
+ License
169
+ -------
170
+
171
+ * Modest engine — `LGPL2.1 <https://github.com/lexborisov/Modest/blob/master/LICENSE>`_
172
+ * selectolax - `MIT <https://github.com/rushter/selectolax/blob/master/LICENSE>`_
@@ -0,0 +1,24 @@
1
+ selectolax/parser.cpython-310-x86_64-linux-gnu.so,sha256=1_hzu3WoD3sdVvxDUfRcUDneqFZvmuJeVjtg_dYFUg4,7064120
2
+ selectolax/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ selectolax/lexbor.pyi,sha256=N2u6ru6bMnJWsjRmzoctM9AHju41FZVr6Iij-gbkNOs,4945
4
+ selectolax/parser.pyx,sha256=2pKAUhY64htRxF5v64Ke7NRNSm1BHAS60wxrmmapJi0,12927
5
+ selectolax/base.pxi,sha256=eiPKlY9gG3l49qJoRQVLl1Ljza6z1k0A-met6sDPcqE,89
6
+ selectolax/utils.pxi,sha256=BCIzfmduFEuCxu_9vIEmjzrcwawOtyW31lDmfEU1wk4,544
7
+ selectolax/parser.c,sha256=NodaVPpvDLnKD8kX08eu9sZNYbzKhb3sT-rBNrRqTAU,1995870
8
+ selectolax/lexbor.cpython-310-x86_64-linux-gnu.so,sha256=xrYQnkreZ5PNyASTrm8_lXcbNMs4KlOusBeoNltPtg8,21018072
9
+ selectolax/parser.pyi,sha256=g8AED0DK6tpLxlgbYtmpzvuUQ1TMGX7hQBi6u5jlbHQ,9908
10
+ selectolax/lexbor.pyx,sha256=HhP93LGdiUmRY3F1ybFQHgz7NG25Ae1RFqhxx7HE9BY,10724
11
+ selectolax/lexbor.pxd,sha256=PwygBdb1blWAQcxXubZS5uffhgcXaqgySNMPFMT02-c,20958
12
+ selectolax/lexbor.c,sha256=Is-9U-NXnZNUGZDh7_HU7ztvIYUMXQVwOOTqujR895c,2134829
13
+ selectolax/__init__.py,sha256=pv9PE2tiw-K1WURMfLBF4GgdNt7OlyPuBRdebSozdz8,175
14
+ selectolax/parser.pxd,sha256=zZlg1vHUg6o4MXaiwKAo5S5hO_DqBGc4_E10qJ2EcM4,24564
15
+ selectolax/modest/selection.pxi,sha256=S55MMxEW2B1oPExB_DRwPM46WoWZU73J3rFRZU1URuQ,6393
16
+ selectolax/modest/node.pxi,sha256=NrMzJnQJDCmgTHpUxpMHDyAfQ_AS_n_Cr_2ryEKjyL0,32550
17
+ selectolax/lexbor/selection.pxi,sha256=PqjvpL6H9uFcmcQWVGfML8FDsTO7tGoZujpA00g9pWk,6444
18
+ selectolax/lexbor/attrs.pxi,sha256=-518D5v70GgMJhtsxWrWcgIMnXg8afECpUubzq8kqqs,3102
19
+ selectolax/lexbor/node.pxi,sha256=1XNzUwCbTYXy4D6rZtHxMpoJ9M-xoprB9wjdsiaWhr0,29346
20
+ selectolax-0.3.23.dist-info/LICENSE,sha256=kYggm2ZJzBgL79x1gCsYsx8rFIYP2IE-BdXRV3Rm0NU,1077
21
+ selectolax-0.3.23.dist-info/top_level.txt,sha256=e5MuEM2PrQzoDlWetkFli9uXSlxa_ktW5jJEihhaI1c,11
22
+ selectolax-0.3.23.dist-info/RECORD,,
23
+ selectolax-0.3.23.dist-info/METADATA,sha256=xHpXGPIqq8TUjDGlKQF-7qyFcTUNUCs94DCpY6shHyA,5681
24
+ selectolax-0.3.23.dist-info/WHEEL,sha256=G6WAJh_GXUMYPkzQt82j5xHS9Nx3k6AYK5BZjp4Pr1U,112
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (75.1.0)
3
+ Root-Is-Purelib: false
4
+ Tag: cp310-cp310-musllinux_1_2_x86_64
5
+
@@ -0,0 +1 @@
1
+ selectolax