selectolax 0.3.21__cp39-cp39-win32.whl → 0.3.23__cp39-cp39-win32.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 +1 -1
- selectolax/lexbor/node.pxi +51 -0
- selectolax/lexbor.c +30286 -15496
- selectolax/lexbor.cp39-win32.pyd +0 -0
- selectolax/lexbor.pyi +2 -2
- selectolax/modest/node.pxi +40 -0
- selectolax/parser.c +34526 -21089
- selectolax/parser.cp39-win32.pyd +0 -0
- {selectolax-0.3.21.dist-info → selectolax-0.3.23.dist-info}/METADATA +3 -2
- selectolax-0.3.23.dist-info/RECORD +24 -0
- {selectolax-0.3.21.dist-info → selectolax-0.3.23.dist-info}/WHEEL +1 -1
- selectolax-0.3.21.dist-info/RECORD +0 -24
- {selectolax-0.3.21.dist-info → selectolax-0.3.23.dist-info}/LICENSE +0 -0
- {selectolax-0.3.21.dist-info → selectolax-0.3.23.dist-info}/top_level.txt +0 -0
selectolax/lexbor.cp39-win32.pyd
CHANGED
|
Binary file
|
selectolax/lexbor.pyi
CHANGED
|
@@ -79,7 +79,7 @@ class LexborNode:
|
|
|
79
79
|
def iter(self, include_text: bool = False) -> Iterator["LexborNode"]: ...
|
|
80
80
|
def unwrap(self) -> None: ...
|
|
81
81
|
def unwrap_tags(self, tags: list[str]) -> None: ...
|
|
82
|
-
def traverse(self,
|
|
82
|
+
def traverse(self, include_text: bool = False) -> Iterator["LexborNode"]: ...
|
|
83
83
|
def replace_with(self, value: bytes | str | "LexborNode") -> None: ...
|
|
84
84
|
def insert_before(self, value: bytes | str | "LexborNode") -> None: ...
|
|
85
85
|
def insert_after(self, value: bytes | str | "LexborNode") -> None: ...
|
|
@@ -119,4 +119,4 @@ class LexborHTMLParser:
|
|
|
119
119
|
def scripts_srcs_contain(self, queries: tuple[str]) -> bool: ...
|
|
120
120
|
def css_matches(self, selector: str) -> bool: ...
|
|
121
121
|
def clone(self) -> "LexborHTMLParser": ...
|
|
122
|
-
def unwrap_tags(self, tags: list[str]) -> None: ...
|
|
122
|
+
def unwrap_tags(self, tags: list[str]) -> None: ...
|
selectolax/modest/node.pxi
CHANGED
|
@@ -712,6 +712,46 @@ cdef class Node:
|
|
|
712
712
|
else:
|
|
713
713
|
raise TypeError("Expected a string or Node instance, but %s found" % type(value).__name__)
|
|
714
714
|
|
|
715
|
+
def insert_child(self, str_or_Node value):
|
|
716
|
+
"""
|
|
717
|
+
Insert a node inside (at the end of) the current Node.
|
|
718
|
+
|
|
719
|
+
Parameters
|
|
720
|
+
----------
|
|
721
|
+
value : str, bytes or Node
|
|
722
|
+
The text or Node instance to insert inside the Node.
|
|
723
|
+
When a text string is passed, it's treated as text. All HTML tags will be escaped.
|
|
724
|
+
Convert and pass the ``Node`` object when you want to work with HTML.
|
|
725
|
+
Does not clone the ``Node`` object.
|
|
726
|
+
All future changes to the passed ``Node`` object will also be taken into account.
|
|
727
|
+
|
|
728
|
+
Examples
|
|
729
|
+
--------
|
|
730
|
+
|
|
731
|
+
>>> tree = HTMLParser('<div>Get <img src=""></div>')
|
|
732
|
+
>>> div = tree.css_first('div')
|
|
733
|
+
>>> div.insert_child('Laptop')
|
|
734
|
+
>>> tree.body.child.html
|
|
735
|
+
'<div>Get <img src="">Laptop</div>'
|
|
736
|
+
|
|
737
|
+
>>> html_parser = HTMLParser('<div>Get <span alt="Laptop"> <div>Laptop</div> </span></div>')
|
|
738
|
+
>>> html_parser2 = HTMLParser('<div>Test</div>')
|
|
739
|
+
>>> span_node = html_parser.css_first('span')
|
|
740
|
+
>>> span_node.insert_child(html_parser2.body.child)
|
|
741
|
+
<div>Get <span alt="Laptop"> <div>Laptop</div> <div>Test</div> </span></div>'
|
|
742
|
+
"""
|
|
743
|
+
cdef myhtml_tree_node_t *node
|
|
744
|
+
if isinstance(value, (str, bytes, unicode)):
|
|
745
|
+
bytes_val = to_bytes(value)
|
|
746
|
+
node = myhtml_node_create(self.parser.html_tree, MyHTML_TAG__TEXT, MyHTML_NAMESPACE_HTML)
|
|
747
|
+
myhtml_node_text_set(node, <char*> bytes_val, len(bytes_val), MyENCODING_UTF_8)
|
|
748
|
+
myhtml_node_append_child(self.node, node)
|
|
749
|
+
elif isinstance(value, Node):
|
|
750
|
+
node = myhtml_node_clone_deep(self.parser.html_tree, <myhtml_tree_node_t *> value.node)
|
|
751
|
+
myhtml_node_append_child(self.node, node)
|
|
752
|
+
else:
|
|
753
|
+
raise TypeError("Expected a string or Node instance, but %s found" % type(value).__name__)
|
|
754
|
+
|
|
715
755
|
def unwrap_tags(self, list tags):
|
|
716
756
|
"""Unwraps specified tags from the HTML tree.
|
|
717
757
|
|