zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
U
¡ý°d]'ã
@s^dZddlZz ddlZWn0ek
rHZzdZe d¡W5dZ[XYnXGdd„deƒZdS)zFIntegration code for CSS selectors using Soup Sieve (pypi: soupsieve).éNzEThe soupsieve package is not installed. CSS selectors cannot be used.c@szeZdZdZefdd„Zdd„Zdd„Zdd    „Zdd d „Z    ddd„Z
ddd„Z ddd„Z ddd„Z ddd„Zd dd„Zd
S)!ÚCSSa±A proxy object against the soupsieve library, to simplify its
    CSS selector API.
 
    Acquire this object through the .css attribute on the
    BeautifulSoup object, or on the Tag you want to use as the
    starting point for a CSS selector.
 
    The main advantage of doing this is that the tag to be selected
    against doesn't need to be explicitly specified in the function
    calls, since it's already scoped to a tag.
    cCs |dkrtdƒ‚||_||_dS)a¹Constructor.
 
        You don't need to instantiate this class yourself; instead,
        access the .css attribute on the BeautifulSoup object, or on
        the Tag you want to use as the starting point for your CSS
        selector.
 
        :param tag: All CSS selectors will use this as their starting
        point.
 
        :param api: A plug-in replacement for the soupsieve module,
        designed mainly for use in tests.
        NzLCannot execute CSS selectors because the soupsieve package is not installed.)ÚNotImplementedErrorÚapiÚtag)Úselfrr©rú>d:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\bs4/css.pyÚ__init__s ÿz CSS.__init__cCstdkrtdƒ‚|j |¡S)z¥Escape a CSS identifier.
 
        This is a simple wrapper around soupselect.escape(). See the
        documentation for that function for more information.
        NzMCannot escape CSS identifiers because the soupsieve package is not installed.)Ú    soupsieverrÚescape)rÚidentrrrr /s
ÿz
CSS.escapecCs"t||jjƒs|dkr|jj}|S)z%Normalize a dictionary of namespaces.N)Ú
isinstancerZ    SoupSieverÚ _namespaces)rÚnsÚselectrrrÚ_ns;szCSS._nscCsddlm}|d|ƒS)aNormalize a list of results to a Resultset.
 
        A ResultSet is more consistent with the rest of Beautiful
        Soup's API, and ResultSet.__getattr__ has a helpful error
        message if you try to treat a list of results as a single
        result (a common mistake).
        r)Ú    ResultSetN)Z bs4.elementr)rÚresultsrrrrÚ_rsDs     zCSS._rsNrcKs|jj|| ||¡|f|ŽS)a~Pre-compile a selector and return the compiled object.
 
        :param selector: A CSS selector.
 
        :param namespaces: A dictionary mapping namespace prefixes
           used in the CSS selector to namespace URIs. By default,
           Beautiful Soup will use the prefixes it encountered while
           parsing the document.
 
        :param flags: Flags to be passed into Soup Sieve's
            soupsieve.compile() method.
 
        :param kwargs: Keyword arguments to be passed into SoupSieve's
           soupsieve.compile() method.
 
        :return: A precompiled selector object.
        :rtype: soupsieve.SoupSieve
        )rÚcompiler©rrÚ
namespacesÚflagsÚkwargsrrrrPs
ÿÿz CSS.compilecKs |jj||j| ||¡|f|ŽS)aKPerform a CSS selection operation on the current Tag and return the
        first result.
 
        This uses the Soup Sieve library. For more information, see
        that library's documentation for the soupsieve.select_one()
        method.
 
        :param selector: A CSS selector.
 
        :param namespaces: A dictionary mapping namespace prefixes
           used in the CSS selector to namespace URIs. By default,
           Beautiful Soup will use the prefixes it encountered while
           parsing the document.
 
        :param flags: Flags to be passed into Soup Sieve's
            soupsieve.select_one() method.
 
        :param kwargs: Keyword arguments to be passed into SoupSieve's
           soupsieve.select_one() method.
 
        :return: A Tag, or None if the selector has no match.
        :rtype: bs4.element.Tag
 
        )rÚ
select_onerrrrrrrgs
ÿÿzCSS.select_onec    Ks4|dkr d}| |jj||j| ||¡||f|Ž¡S)awPerform a CSS selection operation on the current Tag.
 
        This uses the Soup Sieve library. For more information, see
        that library's documentation for the soupsieve.select()
        method.
 
        :param selector: A string containing a CSS selector.
 
        :param namespaces: A dictionary mapping namespace prefixes
            used in the CSS selector to namespace URIs. By default,
            Beautiful Soup will pass in the prefixes it encountered while
            parsing the document.
 
        :param limit: After finding this number of results, stop looking.
 
        :param flags: Flags to be passed into Soup Sieve's
            soupsieve.select() method.
 
        :param kwargs: Keyword arguments to be passed into SoupSieve's
            soupsieve.select() method.
 
        :return: A ResultSet of Tag objects.
        :rtype: bs4.element.ResultSet
 
        Nr)rrrrr©rrrÚlimitrrrrrr„s
ÿþÿz
CSS.selectcKs"|jj||j| ||¡||f|ŽS)a¹Perform a CSS selection operation on the current Tag.
 
        This uses the Soup Sieve library. For more information, see
        that library's documentation for the soupsieve.iselect()
        method. It is the same as select(), but it returns a generator
        instead of a list.
 
        :param selector: A string containing a CSS selector.
 
        :param namespaces: A dictionary mapping namespace prefixes
            used in the CSS selector to namespace URIs. By default,
            Beautiful Soup will pass in the prefixes it encountered while
            parsing the document.
 
        :param limit: After finding this number of results, stop looking.
 
        :param flags: Flags to be passed into Soup Sieve's
            soupsieve.iselect() method.
 
        :param kwargs: Keyword arguments to be passed into SoupSieve's
            soupsieve.iselect() method.
 
        :return: A generator
        :rtype: types.GeneratorType
        )rÚiselectrrrrrrr¨s
ÿÿz CSS.iselectcKs |jj||j| ||¡|f|ŽS)a6Find the Tag closest to this one that matches the given selector.
 
        This uses the Soup Sieve library. For more information, see
        that library's documentation for the soupsieve.closest()
        method.
 
        :param selector: A string containing a CSS selector.
 
        :param namespaces: A dictionary mapping namespace prefixes
            used in the CSS selector to namespace URIs. By default,
            Beautiful Soup will pass in the prefixes it encountered while
            parsing the document.
 
        :param flags: Flags to be passed into Soup Sieve's
            soupsieve.closest() method.
 
        :param kwargs: Keyword arguments to be passed into SoupSieve's
            soupsieve.closest() method.
 
        :return: A Tag, or None if there is no match.
        :rtype: bs4.Tag
 
        )rÚclosestrrrrrrrÆs
ÿÿz CSS.closestcKs |jj||j| ||¡|f|ŽS)aCheck whether this Tag matches the given CSS selector.
 
        This uses the Soup Sieve library. For more information, see
        that library's documentation for the soupsieve.match()
        method.
 
        :param: a CSS selector.
 
        :param namespaces: A dictionary mapping namespace prefixes
            used in the CSS selector to namespace URIs. By default,
            Beautiful Soup will pass in the prefixes it encountered while
            parsing the document.
 
        :param flags: Flags to be passed into Soup Sieve's
            soupsieve.match() method.
 
        :param kwargs: Keyword arguments to be passed into SoupSieve's
            soupsieve.match() method.
 
        :return: True if this Tag matches the selector; False otherwise.
        :rtype: bool
        )rÚmatchrrrrrrrâs
ÿÿz    CSS.matchc    Ks&| |jj||j| ||¡|f|Ž¡S)aWFilter this Tag's direct children based on the given CSS selector.
 
        This uses the Soup Sieve library. It works the same way as
        passing this Tag into that library's soupsieve.filter()
        method. More information, for more information see the
        documentation for soupsieve.filter().
 
        :param namespaces: A dictionary mapping namespace prefixes
            used in the CSS selector to namespace URIs. By default,
            Beautiful Soup will pass in the prefixes it encountered while
            parsing the document.
 
        :param flags: Flags to be passed into Soup Sieve's
            soupsieve.filter() method.
 
        :param kwargs: Keyword arguments to be passed into SoupSieve's
            soupsieve.filter() method.
 
        :return: A ResultSet of Tag objects.
        :rtype: bs4.element.ResultSet
 
        )rrÚfilterrrrrrrr ýs
ÿÿÿz
CSS.filter)Nr)Nr)Nrr)Nrr)Nr)Nr)Nr)Ú__name__Ú
__module__Ú __qualname__Ú__doc__r
r    r rrrrrrrrr rrrrr s      
 
 
$
 
 
r)r$Úwarningsr
Ú ImportErrorÚeÚwarnÚobjectrrrrrÚ<module>s ÿ