zmc
2023-10-12 ed135d79df12a2466b52dae1a82326941211dcc9
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
U
¡ý°d,jã @sdZzddlmZWn.ek
rBZzddlmZW5dZ[XYnXddlZddlZddlZddl    m
Z
ddl m Z m Z mZdZe d¡Ze d¡Zd    d
„Zed d d dddddddddg ƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd „d eƒZGd!d"„d"eeƒZGd#d$„d$eƒZGd%d&„d&eƒZGd'd(„d(eƒZ Gd)d*„d*e ƒZ!Gd+d,„d,eƒZ"Gd-d.„d.eƒZ#Gd/d0„d0eƒZ$Gd1d2„d2eƒZ%Gd3d4„d4eƒZ&Gd5d6„d6eƒZ'Gd7d8„d8eƒZ(Gd9d:„d:eƒZ)Gd;d<„d<eƒZ*Gd=d>„d>eƒZ+Gd?d@„d@e,ƒZ-dS)AÚMITé)ÚCallableN©ÚCSS)Ú    FormatterÚ HTMLFormatterÚ XMLFormatterzutf-8z\S+z\s+cs&t‡fdd„ƒ}|j‡fdd„ƒ}|S)z>Alias one attribute name to another for backward compatibilitycs
t|ˆƒS©N©Úgetattr©Úself©Úattr©úBd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\bs4/element.pyÚaliassz_alias.<locals>.aliascs
t|ˆƒSr    )Úsetattrr rrrr!s)ÚpropertyÚsetter)rrrrrÚ_aliass
rÚidnaÚmbcsÚoemZpalmosÚpunycodeZraw_unicode_escapeZ    undefinedZunicode_escapezraw-unicode-escapeúunicode-escapez string-escapeZ string_escapec@seZdZdZddd„ZdS)ÚNamespacedAttributez†A namespaced string (e.g. 'xml:lang') that remembers the namespace
    ('xml') and the name ('lang') that were used to create it.
    NcCsV|sd}|st ||¡}n&|s,t ||¡}nt ||d|¡}||_||_||_|S)Nú:)ÚstrÚ__new__ÚprefixÚnameÚ    namespace)Úclsr r!r"ÚobjrrrrIszNamespacedAttribute.__new__)NN)Ú__name__Ú
__module__Ú __qualname__Ú__doc__rrrrrrDsrc@seZdZdZdS)Ú%AttributeValueWithCharsetSubstitutionz=A stand-in object for a character encoding specified in HTML.N©r%r&r'r(rrrrr)[sr)c@s eZdZdZdd„Zdd„ZdS)ÚCharsetMetaAttributeValuezÕA generic stand-in for the value of a meta tag's 'charset' attribute.
 
    When Beautiful Soup parses the markup '<meta charset="utf8">', the
    value of the 'charset' attribute will be one of these objects.
    cCst ||¡}||_|Sr    )rrÚoriginal_value)r#r,r$rrrres z!CharsetMetaAttributeValue.__new__cCs|tkr dS|S)zWhen an HTML document is being encoded to a given encoding, the
        value of a meta tag's 'charset' is the name of the encoding.
        Ú)ÚPYTHON_SPECIFIC_ENCODINGS©r ÚencodingrrrÚencodejsz CharsetMetaAttributeValue.encodeN)r%r&r'r(rr1rrrrr+^sr+c@s.eZdZdZe dej¡Zdd„Zdd„Z    dS)ÚContentMetaAttributeValueaA generic stand-in for the value of a meta tag's 'content' attribute.
 
    When Beautiful Soup parses the markup:
     <meta http-equiv="content-type" content="text/html; charset=utf8">
 
    The value of the 'content' attribute will be one of these objects.
    z((^|;)\s*charset=)([^;]*)cCs6|j |¡}|dkr t t|¡St ||¡}||_|Sr    )Ú
CHARSET_REÚsearchrrr,)r#r,Úmatchr$rrrr~s    z!ContentMetaAttributeValue.__new__cs(ˆtkr dS‡fdd„}|j ||j¡S)Nr-cs| d¡ˆS)Né)Úgroup)r5©r0rrÚrewrite‹sz1ContentMetaAttributeValue.encode.<locals>.rewrite)r.r3Úsubr,)r r0r9rr8rr1ˆs z ContentMetaAttributeValue.encodeN)
r%r&r'r(ÚreÚcompileÚMr3rr1rrrrr2ss
r2c@s`eZdZdZdZd\dd„Zdd„Zdd„Zed    d
„ƒZ    e
d ƒZ e
d ƒZ e ƒZd efdd„Zedd„ƒZdd efdd„ZeZeeƒZdd„ZeZdd„ZeZeZdd„Zd]dd„Zd^dd„ZeZd d!„Zd"d#„Zd$d%„Zd&d'„Z d(d)„Z!didfd*d+„Z"e"Z#diddfd,d-„Z$e$Z%didfd.d/„Z&e&Z'diddfd0d1„Z(e(Z)e(Z*didfd2d3„Z+e+Z,diddfd4d5„Z-e-Z.e-Z/didfd6d7„Z0e0Z1diddfd8d9„Z2e2Z3e2Z4difd:d;„Z5e5Z6didfd<d=„Z7e7Z8e7Z9ed>d?„ƒZ:ed@dA„ƒZ;dBdC„Z<dDdE„Z=edFdG„ƒZ>edHdI„ƒZ?edJdK„ƒZ@edLdM„ƒZAedNdO„ƒZBedPdQ„ƒZCdRdS„ZDdTdU„ZEdVdW„ZFdXdY„ZGdZd[„ZHdS)_Ú PageElementz½Contains the navigational information for some part of the page:
    that is, its current location in the parse tree.
 
    NavigableString, Tag, etc. are all subclasses of PageElement.
    NcCsŒ||_||_|dk    r||j_||_|jdk    r4||j_||_|jdk    rL||j_|dkrr|jdk    rr|jjrr|jjd}||_|dk    rˆ||j_dS)aJSets up the initial relations between this element and
        other elements.
 
        :param parent: The parent of this element.
 
        :param previous_element: The element parsed immediately before
            this one.
 
        :param next_element: The element parsed immediately before
            this one.
 
        :param previous_sibling: The most recently encountered element
            on the same level of the parse tree as this one.
 
        :param previous_sibling: The next element to be encountered
            on the same level of the parse tree as this one.
        Néÿÿÿÿ)ÚparentÚprevious_elementÚ next_elementÚ next_siblingÚprevious_siblingÚcontents)r r@rArBrDrCrrrÚsetupœs&
 
ÿÿ zPageElement.setupcCs.|dkr |St|tƒs | |¡}| |¡}|S)z¹Format the given string using the given formatter.
 
        :param s: A string.
        :param formatter: A Formatter object, or a string naming one of the standard formatters.
        N)Ú
isinstancerÚformatter_for_nameÚ
substitute)r ÚsÚ    formatterÚoutputrrrÚ format_stringÅs 
 
 
zPageElement.format_stringcCs<t|tƒr|S|jrt}nt}t|tƒr2||dS|j|S)a|Look up or create a Formatter for the given identifier,
        if necessary.
 
        :param formatter: Can be a Formatter object (used as-is), a
            function (used as the entity substitution hook for an
            XMLFormatter or HTMLFormatter), or a string (used to look
            up an XMLFormatter or HTMLFormatter in the appropriate
            registry.
        )Zentity_substitution)rGrÚ_is_xmlrrrZREGISTRY)r rKÚcrrrrHÒs
 
 
 
zPageElement.formatter_for_namecCs.|jdk    r|jS|jdkr&t|ddƒS|jjS)aIs this element part of an XML tree or an HTML tree?
 
        This is used in formatter_for_name, when deciding whether an
        XMLFormatter or HTMLFormatter is more appropriate. It can be
        inefficient, but it should be called very rarely.
        NÚis_xmlF)Ú    known_xmlr@r rNr rrrrNæs
 
 
 zPageElement._is_xmlrCrDFcCs
tƒ‚dS)zŒYield all strings of certain classes, possibly stripping them.
 
        This is implemented differently in Tag and NavigableString.
        N)ÚNotImplementedError)r ÚstripÚtypesrrrÚ _all_stringsszPageElement._all_stringsccs| d¡D]
}|Vq
dS)zvYield all strings in this PageElement, stripping them first.
 
        :yield: A sequence of stripped strings.
        TN)rU©r ÚstringrrrÚstripped_stringsszPageElement.stripped_stringsr-cCs| dd„|j||dDƒ¡S)a˜Get all child strings of this PageElement, concatenated using the
        given separator.
 
        :param separator: Strings will be concatenated using this separator.
 
        :param strip: If True, strings will be stripped before being
            concatenated.
 
        :param types: A tuple of NavigableString subclasses. Any
            strings of a subclass not found in this list will be
            ignored. Although there are exceptions, the default
            behavior in most cases is to consider only NavigableString
            and CData objects. That means no comments, processing
            instructions, etc.
 
        :return: A string.
        cSsg|]}|‘qSrr)Ú.0rJrrrÚ
<listcomp>$sz(PageElement.get_text.<locals>.<listcomp>)rT)ÚjoinrU)r Ú    separatorrSrTrrrÚget_textsÿzPageElement.get_textcsˆjdkrtdƒ‚t|ƒdkr.|dˆkr.dSt‡fdd„|DƒƒrLtdƒ‚ˆj}ˆj ˆ¡}ˆj|dt||d    D]\}}| ||¡qvˆS)
zÔReplace this PageElement with one or more PageElements, keeping the
        rest of the tree the same.
 
        :param args: One or more PageElements.
        :return: `self`, no longer part of the tree.
        Nz^Cannot replace one element with another when the element to be replaced is not part of a tree.r6rc3s|]}|ˆjkVqdSr    ©r@©rYÚxr rrÚ    <genexpr>6sz+PageElement.replace_with.<locals>.<genexpr>z%Cannot replace a Tag with its parent.©Ú _self_index)Ústart)r@Ú
ValueErrorÚlenÚanyÚindexÚextractÚ    enumerateÚinsert)r ÚargsZ
old_parentÚmy_indexÚidxÚ replace_withrr rro)s
ÿ  zPageElement.replace_withcCsX|j}|jdkrtdƒ‚|j |¡}|j|dt|jdd…ƒD]}| ||¡qB|S)zjReplace this PageElement with its contents.
 
        :return: `self`, no longer part of the tree.
        NzSCannot replace an element with its contents when thatelement is not part of a tree.rb)r@rerhriÚreversedrErk)r Z    my_parentrmÚchildrrrÚunwrap@s
ÿ  zPageElement.unwrapcCs| |¡}| |¡|S)zëWrap this PageElement inside another one.
 
        :param wrap_inside: A PageElement.
        :return: `wrap_inside`, occupying the position in the tree that used
           to be occupied by `self`, and with `self` inside it.
        )roÚappend)r Z wrap_insideÚmerrrÚwrapRs
 
zPageElement.wrapcCsÎ|jdk    r(|dkr|j |¡}|jj|=| ¡}|j}|jdk    rR|j|k    rR||j_|dk    rl||jk    rl|j|_d|_d|_d|_|jdk    rž|j|jk    rž|j|j_|jdk    r¾|j|jk    r¾|j|j_d|_|_|S)aDestructively rips this element out of the tree.
 
        :param _self_index: The location of this element in its parent's
           .contents, if known. Passing this in allows for a performance
           optimization.
 
        :return: `self`, no longer part of the tree.
        N)r@rhrEÚ_last_descendantrBrArDrC)r rcÚ
last_childrBrrrri]s2    
 
 
ÿ
 
ÿ
 
 
ÿ
 zPageElement.extractTcCsL|r|jdk    r|jj}n |}t|tƒr8|jr8|jd}q|sH||krHd}|S)zêFinds the last element beneath this object to be parsed.
 
        :param is_initialized: Has `setup` been called on this PageElement
            yet?
        :param accept_self: Is `self` an acceptable answer to the question?
        Nr?)rCrArGÚTagrE)r Zis_initializedZ accept_selfrwrrrrvƒs
  zPageElement._last_descendantc Csê|dkrtdƒ‚||kr tdƒ‚t|tƒr<t|tƒs<t|ƒ}ddlm}t||ƒrzt|jƒD]}| ||¡|d7}q\dSt    |t
|jƒƒ}t |dƒrÊ|j dk    rÊ|j |krÂ|  |¡}||krÂ|d8}| ¡||_ d}|dkrêd|_||_n(|j|d}||_||j_| d¡|_|jdk    r&||j_| d¡}|t
|jƒkršd|_|}d}    |    dkr€|dk    r€|j}    |j }|    dk    rNq€qN|    dk    r’|    |_nd|_n*|j|}
|
|_|jdk    r¾||j_|
|_|jdk    rØ||j_|j ||¡dS)    a&Insert a new PageElement in the list of this PageElement's children.
 
        This works the same way as `list.insert`.
 
        :param position: The numeric position that should be occupied
           in `self.children` by the new PageElement.
        :param new_child: A PageElement.
        NzCannot insert None into a tag.z Cannot insert a tag into itself.r)Ú BeautifulSoupr6r@F)rerGrÚNavigableStringZbs4ryÚlistrErkÚminrfÚhasattrr@rhrirDrArCrvrB) r ÚpositionÚ    new_childryZsubchildZ current_indexZprevious_childZnew_childs_last_elementr@Zparents_next_siblingZ
next_childrrrrk–sj    
ÿ 
 
 
 
 
 
 
 
  zPageElement.insertcCs| t|jƒ|¡dS)zgAppends the given PageElement to the contents of this one.
 
        :param tag: A PageElement.
        N)rkrfrE)r ÚtagrrrrsèszPageElement.appendcCs:t|tƒr|j}t|tƒr"t|ƒ}|D]}| |¡q&dS)zñAppends the given PageElements to this one's contents.
 
        :param tags: A list of PageElements. If a single Tag is
            provided instead, this PageElement's contents will be extended
            with that Tag's contents.
        N)rGrxrEr{rs)r Útagsr€rrrÚextendïs 
 
zPageElement.extendcsjˆj}|dkrtdƒ‚t‡fdd„|Dƒƒr4tdƒ‚|D],}t|tƒrN| ¡| ˆ¡}| ||¡q8dS)zóMakes the given element(s) the immediate predecessor of this one.
 
        All the elements will have the same parent, and the given elements
        will be immediately before this one.
 
        :param args: One or more PageElements.
        Nz2Element has no parent, so 'before' has no meaning.c3s|]}|ˆkVqdSr    rr_r rrra sz,PageElement.insert_before.<locals>.<genexpr>z&Can't insert an element before itself.©r@rergrGr>rirhrk)r rlr@Z predecessorrhrr rÚ insert_beforeÿsÿ
 
zPageElement.insert_beforecs~ˆj}|dkrtdƒ‚t‡fdd„|Dƒƒr4tdƒ‚d}|D]<}t|tƒrR| ¡| ˆ¡}| |d||¡|d7}q<dS)zìMakes the given element(s) the immediate successor of this one.
 
        The elements will have the same parent, and the given elements
        will be immediately after this one.
 
        :param args: One or more PageElements.
        Nz1Element has no parent, so 'after' has no meaning.c3s|]}|ˆkVqdSr    rr_r rrra"sz+PageElement.insert_after.<locals>.<genexpr>z%Can't insert an element after itself.rr6rƒ)r rlr@ÚoffsetÚ    successorrhrr rÚ insert_afters    ÿ
 
zPageElement.insert_aftercKs|j|j|||f|ŽS)aUFind the first PageElement that matches the given criteria and
        appears later in the document than this PageElement.
 
        All find_* methods take a common set of arguments. See the online
        documentation for detailed explanations.
 
        :param name: A filter on tag name.
        :param attrs: A dictionary of filters on attribute values.
        :param string: A filter for a NavigableString with specific text.
        :kwargs: A dictionary of filters on attribute values.
        :return: A PageElement.
        :rtype: bs4.element.Tag | bs4.element.NavigableString
        )Ú    _find_oneÚ find_all_next©r r!ÚattrsrWÚkwargsrrrÚ    find_next/szPageElement.find_nextcKs0| dd¡}|j|||||jfd|di|—ŽS)aiFind all PageElements that match the given criteria and appear
        later in the document than this PageElement.
 
        All find_* methods take a common set of arguments. See the online
        documentation for detailed explanations.
 
        :param name: A filter on tag name.
        :param attrs: A dictionary of filters on attribute values.
        :param string: A filter for a NavigableString with specific text.
        :param limit: Stop looking after finding this many results.
        :kwargs: A dictionary of filters on attribute values.
        :return: A ResultSet containing PageElements.
        Ú _stacklevelér6)ÚpopÚ    _find_allÚ next_elements©r r!r‹rWÚlimitrŒrŽrrrr‰@s  ÿÿzPageElement.find_all_nextcKs|j|j|||f|ŽS)aQFind the closest sibling to this PageElement that matches the
        given criteria and appears later in the document.
 
        All find_* methods take a common set of arguments. See the
        online documentation for detailed explanations.
 
        :param name: A filter on tag name.
        :param attrs: A dictionary of filters on attribute values.
        :param string: A filter for a NavigableString with specific text.
        :kwargs: A dictionary of filters on attribute values.
        :return: A PageElement.
        :rtype: bs4.element.Tag | bs4.element.NavigableString
        )rˆÚfind_next_siblingsrŠrrrÚfind_next_siblingTsÿzPageElement.find_next_siblingcKs0| dd¡}|j|||||jfd|di|—ŽS)aFind all siblings of this PageElement that match the given criteria
        and appear later in the document.
 
        All find_* methods take a common set of arguments. See the online
        documentation for detailed explanations.
 
        :param name: A filter on tag name.
        :param attrs: A dictionary of filters on attribute values.
        :param string: A filter for a NavigableString with specific text.
        :param limit: Stop looking after finding this many results.
        :kwargs: A dictionary of filters on attribute values.
        :return: A ResultSet of PageElements.
        :rtype: bs4.element.ResultSet
        rŽrr6)rr‘Ú next_siblingsr“rrrr•fs þþþzPageElement.find_next_siblingscKs|j|j|||f|ŽS)aVLook backwards in the document from this PageElement and find the
        first PageElement that matches the given criteria.
 
        All find_* methods take a common set of arguments. See the online
        documentation for detailed explanations.
 
        :param name: A filter on tag name.
        :param attrs: A dictionary of filters on attribute values.
        :param string: A filter for a NavigableString with specific text.
        :kwargs: A dictionary of filters on attribute values.
        :return: A PageElement.
        :rtype: bs4.element.Tag | bs4.element.NavigableString
        )rˆÚfind_all_previousrŠrrrÚ find_previous~sÿÿzPageElement.find_previouscKs0| dd¡}|j|||||jfd|di|—ŽS)a‰Look backwards in the document from this PageElement and find all
        PageElements that match the given criteria.
 
        All find_* methods take a common set of arguments. See the online
        documentation for detailed explanations.
 
        :param name: A filter on tag name.
        :param attrs: A dictionary of filters on attribute values.
        :param string: A filter for a NavigableString with specific text.
        :param limit: Stop looking after finding this many results.
        :kwargs: A dictionary of filters on attribute values.
        :return: A ResultSet of PageElements.
        :rtype: bs4.element.ResultSet
        rŽrr6)rr‘Úprevious_elementsr“rrrr˜s ÿþþzPageElement.find_all_previouscKs|j|j|||f|ŽS)aVReturns the closest sibling to this PageElement that matches the
        given criteria and appears earlier in the document.
 
        All find_* methods take a common set of arguments. See the online
        documentation for detailed explanations.
 
        :param name: A filter on tag name.
        :param attrs: A dictionary of filters on attribute values.
        :param string: A filter for a NavigableString with specific text.
        :kwargs: A dictionary of filters on attribute values.
        :return: A PageElement.
        :rtype: bs4.element.Tag | bs4.element.NavigableString
        )rˆÚfind_previous_siblingsrŠrrrÚfind_previous_sibling¨sÿz!PageElement.find_previous_siblingcKs0| dd¡}|j|||||jfd|di|—ŽS)a†Returns all siblings to this PageElement that match the
        given criteria and appear earlier in the document.
 
        All find_* methods take a common set of arguments. See the online
        documentation for detailed explanations.
 
        :param name: A filter on tag name.
        :param attrs: A dictionary of filters on attribute values.
        :param string: A filter for a NavigableString with specific text.
        :param limit: Stop looking after finding this many results.
        :kwargs: A dictionary of filters on attribute values.
        :return: A ResultSet of PageElements.
        :rtype: bs4.element.ResultSet
        rŽrr6)rr‘Úprevious_siblingsr“rrrr›ºs þþþz"PageElement.find_previous_siblingscKs.d}|j||dfddi|—Ž}|r*|d}|S)aåFind the closest parent of this PageElement that matches the given
        criteria.
 
        All find_* methods take a common set of arguments. See the online
        documentation for detailed explanations.
 
        :param name: A filter on tag name.
        :param attrs: A dictionary of filters on attribute values.
        :kwargs: A dictionary of filters on attribute values.
 
        :return: A PageElement.
        :rtype: bs4.element.Tag | bs4.element.NavigableString
        Nr6rŽér)Ú find_parents)r r!r‹rŒÚrÚlrrrÚ find_parentÒs
zPageElement.find_parentcKs0| dd¡}|j||d||jfd|di|—ŽS)aFind all parents of this PageElement that match the given criteria.
 
        All find_* methods take a common set of arguments. See the online
        documentation for detailed explanations.
 
        :param name: A filter on tag name.
        :param attrs: A dictionary of filters on attribute values.
        :param limit: Stop looking after finding this many results.
        :kwargs: A dictionary of filters on attribute values.
 
        :return: A PageElement.
        :rtype: bs4.element.Tag | bs4.element.NavigableString
        rŽrNr6)rr‘Úparents)r r!r‹r”rŒrŽrrrrŸés  ÿÿzPageElement.find_parentscCs|jS)z¥The PageElement, if any, that was parsed just after this one.
 
        :return: A PageElement.
        :rtype: bs4.element.Tag | bs4.element.NavigableString
        ©rBr rrrÚnextýszPageElement.nextcCs|jS)z¦The PageElement, if any, that was parsed just before this one.
 
        :return: A PageElement.
        :rtype: bs4.element.Tag | bs4.element.NavigableString
        ©rAr rrrÚpreviousszPageElement.previouscKs.d}||||dfddi|—Ž}|r*|d}|S)Nr6rŽérr)r Úmethodr!r‹rWrŒr r¡rrrrˆs
zPageElement._find_onec  sL| dd¡}|dkr6d|kr6| d¡}tjdt|dtˆtƒrFˆ}ntˆ||f|Ž}|dkrä|sä|sä|säˆdkszˆdkr’dd    „|Dƒ}    t||    ƒStˆtƒr䈠d
¡d kr¼ˆ     d
d ¡\‰‰nd‰ˆ‰‡‡‡fd d    „|Dƒ}    t||    ƒSt|ƒ}
z t
|ƒ} Wnt k
rYqHYnX| rì|  | ¡} | rì|
  | ¡|rìt|
ƒ|krìqHqì|
S) z8Iterates over a generator looking for things that match.rŽržNÚtextzOThe 'text' argument to find()-type methods is deprecated. Use 'string' instead.©Ú
stacklevelTcss|]}t|tƒr|VqdSr    )rGrx©rYÚelementrrrra+s
ÿz(PageElement._find_all.<locals>.<genexpr>rr6c3sB|]:}t|tƒr|jˆks6|jˆkrˆdks6|jˆkr|VqdSr    )rGrxr!r r­©Z
local_namer!r rrra8s
 
 
 
ú)rÚwarningsÚwarnÚDeprecationWarningrGÚ SoupStrainerÚ    ResultSetrÚcountÚsplitr¥Ú StopIterationr4rsrf) r r!r‹rWr”Ú    generatorrŒrŽZstrainerÚresultÚresultsÚiÚfoundrr¯rr‘sD 
þ
 
 
    
 
 
zPageElement._find_allccs |j}|dk    r|V|j}qdS)zgAll PageElements that were parsed after this one.
 
        :yield: A sequence of PageElements.
        Nr¤©r r»rrrr’RszPageElement.next_elementsccs |j}|dk    r|V|j}qdS)zƒAll PageElements that are siblings of this one but were parsed
        later.
 
        :yield: A sequence of PageElements.
        N)rCr½rrrr—]szPageElement.next_siblingsccs |j}|dk    r|V|j}qdS)zhAll PageElements that were parsed before this one.
 
        :yield: A sequence of PageElements.
        Nr¦r½rrrršiszPageElement.previous_elementsccs |j}|dk    r|V|j}qdS)z…All PageElements that are siblings of this one but were parsed
        earlier.
 
        :yield: A sequence of PageElements.
        N)rDr½rrrrtszPageElement.previous_siblingsccs |j}|dk    r|V|j}qdS)zlAll PageElements that are parents of this PageElement.
 
        :yield: A sequence of PageElements.
        Nr^r½rrrr£€szPageElement.parentscCst|ddƒpdS)zOCheck whether a PageElement has been decomposed.
 
        :rtype: bool
        Ú _decomposedFr
r rrrÚ
decomposed‹szPageElement.decomposedcCs|jSr    )r’r rrrÚ nextGenerator•szPageElement.nextGeneratorcCs|jSr    )r—r rrrÚnextSiblingGenerator˜sz PageElement.nextSiblingGeneratorcCs|jSr    )ršr rrrÚpreviousGenerator›szPageElement.previousGeneratorcCs|jSr    )rr rrrÚpreviousSiblingGeneratoržsz$PageElement.previousSiblingGeneratorcCs|jSr    )r£r rrrÚparentGenerator¡szPageElement.parentGenerator)NNNNN)N)TT)Ir%r&r'r(rQrFrMrHrrNrZ nextSiblingZpreviousSiblingÚobjectÚdefaultrUrXr]ZgetTextrªroÚ replaceWithrrZreplace_with_childrenZreplaceWithChildrenrurirvZ_lastRecursiveChildrkrsr‚r„r‡rZfindNextr‰Z findAllNextr–ZfindNextSiblingr•ZfindNextSiblingsZfetchNextSiblingsr™Z findPreviousr˜ZfindAllPreviousZ fetchPreviousrœZfindPreviousSiblingr›ZfindPreviousSiblingsZfetchPreviousSiblingsr¢Z
findParentrŸZ findParentsZ fetchParentsr¥r§rˆr‘r’r—ršrr£r¿rÀrÁrÂrÃrÄrrrrr>s¨    ÿ
) 
 
ÿ
 
&
Rÿ
 
 
 
:
 
 
 
 
 
 
 
 
    r>c@s~eZdZdZdZdZdd„Zddd„Zdd    „Zd
d „Z    d d „Z
ddd„Z e dd„ƒZ e jdd„ƒZ dejfdd„Ze eƒZdS)rzz´A Python Unicode string that is part of a parse tree.
 
    When Beautiful Soup parses the markup <b>penguin</b>, it will
    create a NavigableString for the string "penguin".
    r-cCs2t|tƒrt ||¡}nt ||t¡}| ¡|S)a-Create a new NavigableString.
 
        When unpickling a NavigableString, this method is called with
        the string in DEFAULT_OUTPUT_ENCODING. That encoding needs to be
        passed in to the superclass's __new__ or the superclass won't know
        how to handle non-ASCII characters.
        )rGrrÚDEFAULT_OUTPUT_ENCODINGrF)r#ÚvalueÚurrrr¯s
 
zNavigableString.__new__FcCs t|ƒ|ƒS)a>A copy of a NavigableString has the same contents and class
        as the original, but it is not connected to the parse tree.
 
        :param recursive: This parameter is ignored; it's only defined
           so that NavigableString.__deepcopy__ implements the same
           signature as Tag.__deepcopy__.
        )Útype)r ÚmemoÚ    recursiverrrÚ __deepcopy__¾szNavigableString.__deepcopy__cCs
| i¡S)zŒA copy of a NavigableString can only be a deep copy, because
        only one PageElement can occupy a given place in a parse tree.
        ©rÎr rrrÚ__copy__ÈszNavigableString.__copy__cCs
t|ƒfSr    )rr rrrÚ__getnewargs__ÎszNavigableString.__getnewargs__cCs$|dkr |Std|jj|fƒ‚dS)zªtext.string gives you text. This is for backwards
        compatibility for Navigable*String, but for CData* it lets you
        get the string without the CData wrapper.rWú!'%s' object has no attribute '%s'N)ÚAttributeErrorÚ    __class__r%)r rrrrÚ __getattr__ÑsÿÿzNavigableString.__getattr__ÚminimalcCs| ||¡}|j||jS)z™Run the string through the provided formatter.
 
        :param formatter: A Formatter object, or a string naming one of the standard formatters.
        ©rMÚPREFIXÚSUFFIX)r rKrLrrrÚ output_readyÜs zNavigableString.output_readycCsdS)z÷Since a NavigableString is not a Tag, it has no .name.
 
        This property is implemented so that code like this doesn't crash
        when run on a mixture of Tag and NavigableString objects:
            [x.name for x in tag.children]
        Nrr rrrr!äszNavigableString.namecCs tdƒ‚dS)z1Prevent NavigableString.name from ever being set.z)A NavigableString cannot be given a name.N©rÓ)r r!rrrr!îsccsj||jkrtj}t|ƒ}|dk    rDt|tƒr8||k    rDdSn ||krDdS|}|rT| ¡}t|ƒdkrf|VdS)aïYield all strings of certain classes, possibly stripping them.
 
        This makes it easy for NavigableString to implement methods
        like get_text() as conveniences, creating a consistent
        text-extraction API across all PageElements.
 
        :param strip: If True, all strings will be stripped before being
            yielded.
 
        :param types: A tuple of NavigableString subclasses. If this
            NavigableString isn't one of those subclasses, the
            sequence will be empty. By default, the subclasses
            considered are NavigableString and CData objects. That
            means no comments, processing instructions, etc.
 
        :yield: A sequence that either contains this string, or is empty.
 
        Nr)rÆrxÚ DEFAULT_INTERESTING_STRING_TYPESrËrGrSrf)r rSrTZmy_typerÉrrrrUós
    
 zNavigableString._all_stringsN)F)rÖ)r%r&r'r(rØrÙrrÎrÐrÑrÕrÚrr!rr>rÆrUÚstringsrrrrrz¥s
 
 
 
    
.rzc@s"eZdZdZdZdZddd„ZdS)ÚPreformattedStringzÔA NavigableString not subject to the normal formatting rules.
 
    This is an abstract class used for special kinds of strings such
    as comments (the Comment class) and CDATA blocks (the CData
    class).
    r-NcCs$|dk    r| ||¡}|j||jS)a¿Make this string ready for output by adding any subclass-specific
            prefix or suffix.
 
        :param formatter: A Formatter object, or a string naming one
            of the standard formatters. The string will be passed into the
            Formatter, but only to trigger any side effects: the return
            value is ignored.
 
        :return: The string, with any subclass-specific prefix and
           suffix added on.
        Nr×)r rKÚignorerrrrÚ.s  zPreformattedString.output_ready)N)r%r&r'r(rØrÙrÚrrrrrÞ#srÞc@seZdZdZdZdZdS)ÚCDatazA CDATA block.z    <![CDATA[z]]>N©r%r&r'r(rØrÙrrrrrà>sràc@seZdZdZdZdZdS)ÚProcessingInstructionzA SGML processing instruction.ú<?ú>NrárrrrrâCsrâc@seZdZdZdZdZdS)ÚXMLProcessingInstructionzAn XML processing instruction.rãú?>NrárrrrråIsråc@seZdZdZdZdZdS)ÚCommentzAn HTML or XML comment.z<!--z-->NrárrrrrçNsrçc@seZdZdZdZdZdS)Ú DeclarationzAn XML declaration.rãræNrárrrrrèTsrèc@s$eZdZdZedd„ƒZdZdZdS)ÚDoctypezA document type declaration.cCsN|pd}|dk    r2|d|7}|dk    rF|d|7}n|dk    rF|d|7}t|ƒS)aÜGenerate an appropriate document type declaration for a given
        public ID and system ID.
 
        :param name: The name of the document's root element, e.g. 'html'.
        :param pub_id: The Formal Public Identifier for this document type,
            e.g. '-//W3C//DTD XHTML 1.1//EN'
        :param system_id: The system identifier for this document type,
            e.g. 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'
 
        :return: A Doctype.
        r-Nz  PUBLIC "%s"z "%s"z  SYSTEM "%s")ré)r#r!Zpub_idÚ    system_idrÉrrrÚfor_name_and_ids\s   zDoctype.for_name_and_idsz
<!DOCTYPE z>
N)r%r&r'r(Ú classmethodrërØrÙrrrrréZs
 
réc@seZdZdZdS)Ú
Stylesheetz‰A NavigableString representing an stylesheet (probably
    CSS).
 
    Used to distinguish embedded stylesheets from textual content.
    Nr*rrrrríwsríc@seZdZdZdS)ÚScriptz’A NavigableString representing an executable script (probably
    Javascript).
 
    Used to distinguish executable code from textual content.
    Nr*rrrrrî€srîc@seZdZdZdS)ÚTemplateStringz·A NavigableString representing a string found inside an HTML
    template embedded in a larger document.
 
    Used to distinguish such strings from the main body of the document.
    Nr*rrrrrï‰srïc@seZdZdZdS)ÚRubyTextStringzóA NavigableString representing the contents of the <rt> HTML
    element.
 
    https://dev.w3.org/html5/spec-LC/text-level-semantics.html#the-rt-element
 
    Can be used to distinguish such strings from the strings they're
    annotating.
    Nr*rrrrrð’srðc@seZdZdZdS)ÚRubyParenthesisStringzA NavigableString representing the contents of the <rp> HTML
    element.
 
    https://dev.w3.org/html5/spec-LC/text-level-semantics.html#the-rp-element
    Nr*rrrrrñžsrñc@sfeZdZdZdndd„ZedƒZdodd„Zd    d
„Zd d „Z    e
d d„ƒZ e Z e
dd„ƒZ e jdd„ƒZ eefZdejfdd„Ze
eƒZdd„Zdpdd„Zdd„Zdd„Zdqdd„Zdrdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Z d+d,„Z!d-d.„Z"d/d0„Z#d1d2„Z$d3d4„Z%d5d6„Z&d7d8„Z'd9d:„Z(dsd<d=„Z)d>d?„Z*e*Z+Z)e,dd@dAfdBdC„Z-de,d@dfdDdE„Z.e/ƒZ0e/ƒZ1e/ƒZ2e/ƒZ3dtdFdG„Z4dHdI„Z5dJdK„Z6dudMdN„Z7dvdOdP„Z8de,d@fdQdR„Z9de,d@fdSdT„Z:e,ddUfdVdW„Z;diddfdXdY„Z<e<Z=didddfdZd[„Z>e>Z?e>Z@e
d\d]„ƒZAe
d^d_„ƒZBe
d`da„ƒZCdwdbdc„ZDdxddde„ZEe
dfdg„ƒZFdhdi„ZGdjdk„ZHdldm„ZIdS)yrxzáRepresents an HTML or XML tag that is part of a parse tree, along
    with its attributes and contents.
 
    When Beautiful Soup parses the markup <b>penguin</b>, it will
    create a Tag object representing the <b> tag.
    NcCsR|dkrd|_n|j|_|dkr(tdƒ‚||_||_|p:i|_||_|rN|jrj|
dk    s^| dk    rj|
|_| |_    |dkrxi}n4|r¤|dk    rš|j
rš|  |j|¡}q¬t |ƒ}nt |ƒ}|rº|j |_n|    |_||_g|_| ||¡d|_|dkr| |_| |_
||_||_nL| |¡| |¡|_|j
|_
|j|_|j|jkrF|j|j|_n|j|_dS)aMBasic constructor.
 
        :param parser: A BeautifulSoup object.
        :param builder: A TreeBuilder.
        :param name: The name of the tag.
        :param namespace: The URI of this Tag's XML namespace, if any.
        :param prefix: The prefix for this Tag's XML namespace, if any.
        :param attrs: A dictionary of this Tag's attribute values.
        :param parent: The PageElement to use as this Tag's parent.
        :param previous: The PageElement that was parsed immediately before
            this tag.
        :param is_xml: If True, this is an XML tag. Otherwise, this is an
            HTML tag.
        :param sourceline: The line number where this tag was found in its
            source document.
        :param sourcepos: The character position within `sourceline` where this
            tag was found.
        :param can_be_empty_element: If True, this tag should be
            represented as <tag/>. If False, this tag should be represented
            as <tag></tag>.
        :param cdata_list_attributes: A list of attributes whose values should
            be treated as CDATA if they ever show up on this tag.
        :param preserve_whitespace_tags: A list of tag names whose contents
            should have their whitespace preserved.
        :param interesting_string_types: This is a NavigableString
            subclass or a tuple of them. When iterating over this
            Tag's strings in methods like Tag.strings or Tag.get_text,
            these are the types of strings that are interesting enough
            to be considered. The default is to consider
            NavigableString and CData the only interesting string
            subtypes.
        :param namespaces: A dictionary mapping currently active
            namespace prefixes to URIs. This can be used later to
            construct CSS selectors.
        Nz%No value provided for new tag's name.F)Ú parser_classrÔrer!r"Ú _namespacesr Zstore_line_numbersÚ
sourcelineÚ    sourceposÚcdata_list_attributesZ$_replace_cdata_list_attribute_valuesÚdictrPrQr‹rErFÚhiddenÚcan_be_empty_elementÚpreserve_whitespace_tagsÚinteresting_string_typesZset_up_substitutionsZstring_containersrÜ)r ÚparserÚbuilderr!r"r r‹r@r§rPrôrõrùrörúrûÚ
namespacesrrrÚ__init__¯sZ+
 
ÿÿÿ
 
 
 
 
z Tag.__init__ròTcCsp| ¡}|rl|g}| |j¡D]L\}}|tjkr:| ¡q|j|dd}|d |¡|tjkr| |¡q|S)z„A deepcopy of a Tag is a new Tag, unconnected to the parse tree.
        Its contents are a copy of the old Tag's contents.
        F)rÍr?)    Ú_cloneÚ _event_streamÚ descendantsrxÚEND_ELEMENT_EVENTrrÎrsÚSTART_ELEMENT_EVENT)r rÌrÍÚcloneÚ    tag_stackÚeventr®Zdescendant_clonerrrrÎ&s
 
ÿ
 zTag.__deepcopy__cCs
| i¡S)zyA copy of a Tag must always be a deep copy, because a Tag's
        children can only have one parent at a time.
        rÏr rrrrÐBsz Tag.__copy__cCs^t|ƒd|j|j|j|j|j|j|j|j|j    |j
|j |j d }dD]}t ||t||ƒƒqB|S)z¥Create a new Tag just like this one, but with no
        contents and unattached to any parse tree.
 
        This is the first step in the deepcopy process.
        N)rPrôrõrùrörúrû)rùrø)rËrýr!r"r r‹rNrôrõrùrörúrûrr )r rrrrrrHs$ù    z
Tag._clonecCst|jƒdko|jS)a7Is this tag an empty-element tag? (aka a self-closing tag)
 
        A tag that has contents is never an empty-element tag.
 
        A tag that has no contents may or may not be an empty-element
        tag. It depends on the builder used to create the tag. If the
        builder has a designated list of empty-element tags, then only
        a tag whose name shows up in that list is considered an
        empty-element tag.
 
        If the builder has no designated list of empty-element tags,
        then any tag with no contents is an empty-element tag.
        r)rfrErùr rrrÚis_empty_element[szTag.is_empty_elementcCs0t|jƒdkrdS|jd}t|tƒr*|S|jS)aýConvenience property to get the single string within this
        PageElement.
 
        TODO It might make sense to have NavigableString.string return
        itself.
 
        :return: If this element has a single string child, return
         value is that string. If this element has one child tag,
         return value is the 'string' attribute of the child tag,
         recursively. If this element is itself a string, has no
         children, or has more than one child, return value is None.
        r6Nr)rfrErGrzrW)r rqrrrrWms 
 
z
Tag.stringcCs| ¡| | |¡¡dS)z2Replace this PageElement's contents with `string`.N)ÚclearrsrÔrVrrrrW‚sFccs„||jkr|j}|jD]h}|dkr.t|tƒs.qt|ƒ}t|tƒrL||k    r^qn|dk    r^||kr^q|rx| ¡}t|ƒdkrxq|VqdS)a|Yield all strings of certain classes, possibly stripping them.
 
        :param strip: If True, all strings will be stripped before being
            yielded.
 
        :param types: A tuple of NavigableString subclasses. Any strings of
            a subclass not found in this list will be ignored. By
            default, the subclasses considered are the ones found in
            self.interesting_string_types. If that's not specified,
            only NavigableString and CData objects will be
            considered. That means no comments, processing
            instructions, etc.
 
        :yield: A sequence of strings.
 
        Nr)rÆrûrrGrzrËrSrf)r rSrTZ
descendantZdescendant_typerrrrU‰s 
 
 
 zTag._all_stringscCs:| ¡|}|dk    r6|j}|j ¡g|_d|_|}q dS)a–Recursively destroys this PageElement and its children.
 
        This element will be removed from the tree and wiped out; so
        will everything beneath it.
 
        The behavior of a decomposed PageElement is undefined and you
        should never use one for anything, but if you need to _check_
        whether an element has been decomposed, you can use the
        `decomposed` property.
        NT)rirBÚ__dict__r    rEr¾)r r»ÚnrrrÚ    decompose¯s 
z Tag.decomposecCsV|r6|jdd…D] }t|tƒr*| ¡q| ¡qn|jdd…D] }| ¡qDdS)zàWipe out all children of this PageElement by calling extract()
           on them.
 
        :param decompose: If this is True, decompose() (a more
            destructive method) will be called instead of extract().
        N)rErGrxr ri)r r r®rrrr    Ãs
 
 z    Tag.clearcCsÆg}t|jƒD]n\}}t|tƒr(| ¡|t|jƒdkr<q|j|d}t|tƒrt|tƒrt|tƒst|tƒs| |¡qt    |ƒD]:}|j|}|j|d}| 
¡t||ƒ}|  |¡q†dS)zÓSmooth out this element's children by consolidating consecutive
        strings.
 
        This makes pretty-printed output look more natural following a
        lot of operations that modified the tree.
        r6N) rjrErGrxÚsmoothrfrzrÞrsrpriro)r Zmarkedr»ÚaÚbr rrrr Ôs* 
 
ÿþý  
 z
Tag.smoothcCs0t|jƒD]\}}||kr
|Sq
tdƒ‚dS)zæFind the index of a child by identity, not value.
 
        Avoids issues with tag.contents.index(element) getting the
        index of equal elements.
 
        :param element: Look for this PageElement in `self.contents`.
        zTag.index: element not in tagN)rjrEre)r r®r»rqrrrrhús
z    Tag.indexcCs|j ||¡S)z‰Returns the value of the 'key' attribute for the tag, or
        the value given for 'default' if it doesn't have that
        attribute.)r‹Úget)r ÚkeyrÆrrrrszTag.getcCs | ||¡}t|tƒs|g}|S)a&The same as get(), but always returns a list.
 
        :param key: The attribute to look for.
        :param default: Use this value if the attribute is not present
            on this PageElement.
        :return: A list of values, probably containing only a single
            value.
        )rrGr{)r rrÆrÉrrrÚget_attribute_list s     
zTag.get_attribute_listcCs
||jkS)z<Does this PageElement have an attribute with the given name?©r‹©r rrrrÚhas_attrsz Tag.has_attrcCs t|ƒ ¡Sr    )rÚ__hash__r rrrrsz Tag.__hash__cCs
|j|S)zqtag[key] returns the value of the 'key' attribute for the Tag,
        and throws an exception if it's not there.rrrrrÚ __getitem__"szTag.__getitem__cCs
t|jƒS)z0Iterating over a Tag iterates over its contents.©ÚiterrEr rrrÚ__iter__'sz Tag.__iter__cCs
t|jƒS)z:The length of a Tag is the length of its list of contents.)rfrEr rrrÚ__len__+sz Tag.__len__cCs
||jkSr    )rE)r r`rrrÚ __contains__/szTag.__contains__cCsdS)z-A tag is non-None even if it has no contents.Trr rrrÚ__bool__2sz Tag.__bool__cCs||j|<dS)zKSetting tag[key] sets the value of the 'key' attribute for the
        tag.Nr)r rrÉrrrÚ __setitem__6szTag.__setitem__cCs|j |d¡dS)z;Deleting tag[key] deletes all 'key' attributes for the tag.N)r‹rrrrrÚ __delitem__;szTag.__delitem__cOs |j||ŽS)z Calling a Tag like a function is the same as calling its
        find_all() method. Eg. tag('a') returns a list of all the A tags
        found within this tag.©Úfind_all)r rlrŒrrrÚ__call__?sz Tag.__call__cCsxt|ƒdkrF| d¡rF|dd…}tjdt|dtdd| |¡S| d    ¡sb|d
ksb| |¡Std |j    |fƒ‚dS) zACalling tag.subtag is the same as calling tag.find(name="subtag")ržrxNéýÿÿÿzŒ.%(name)sTag is deprecated, use .find("%(name)s") instead. If you really were looking for a tag called %(name)sTag, use .find("%(name)sTag"))r!rr«Ú__rErÒ)
rfÚendswithr°r±r÷r²ÚfindÚ
startswithrÓrÔ)r r€Ztag_namerrrrÕEs ÿü
 
 ÿzTag.__getattr__cCs‚||kr dSt|dƒrRt|dƒrRt|dƒrR|j|jksR|j|jksRt|ƒt|ƒkrVdSt|jƒD]\}}||j|kr`dSq`dS)zyReturns true iff this Tag has the same name, the same attributes,
        and the same contents (recursively) as `other`.Tr!r‹rEF)r}r!r‹rfrjrE)r Úotherr»Zmy_childrrrÚ__eq__Xs$
ÿþ
ý
üûz
Tag.__eq__cCs
||k S)zTReturns true iff this Tag is not identical to `other`,
        as defined in __eq__.r)r r(rrrÚ__ne__isz
Tag.__ne__rcCs| ¡S)zûRenders this PageElement as a string.
 
        :param encoding: The encoding to use (Python 2 only).
            TODO: This is now ignored and a warning should be issued
            if a value is provided.
        :return: A (Unicode) string.
        ©Údecoder/rrrÚ__repr__ns    z Tag.__repr__cCs| ¡S)z-Renders this PageElement as a Unicode string.r+r rrrÚ __unicode__yszTag.__unicode__rÖÚxmlcharrefreplacecCs| |||¡}| ||¡S)aRender a bytestring representation of this PageElement and its
        contents.
 
        :param encoding: The destination encoding.
        :param indent_level: Each line of the rendering will be
           indented this many levels. (The formatter decides what a
           'level' means in terms of spaces or other characters
           output.) Used internally in recursive calls while
           pretty-printing.
        :param formatter: A Formatter object, or a string naming one of
            the standard formatters.
        :param errors: An error handling strategy such as
            'xmlcharrefreplace'. This value is passed along into
            encode() and its value should be one of the constants
            defined by Python.
        :return: A bytestring.
 
        ©r,r1)r r0Ú indent_levelrKÚerrorsrÊrrrr1sz
Tag.encodec CsXg}t|tƒs| |¡}|dkr$d}d}| |¡D]\}}|tjtjfkr^|j||dd}    n6|tjkrŠ|j||dd}    |dk    r”|d8}n
|     |¡}    |r¢d}
} nd}
} |tjkrÎ|sÎ| 
¡sÎd}
d} |}n|tjkrì||krìd}
d} d}|dk    rB|
s| r.t|t ƒr|      ¡}    |    r.|  |    |||
| ¡}    |tjkrB|d7}| |    ¡q2d |¡S)NTr)ÚopeningFr6r-)rGrrHrrxrÚEMPTY_ELEMENT_EVENTÚ _format_tagrrÚÚ_should_pretty_printrzrSÚ_indent_stringrsr[) r r1Úeventual_encodingrKÚiteratorÚpiecesZstring_literal_tagrr®ZpieceÚ indent_beforeÚ indent_afterrrrr,™sn
 
ÿ
ÿ
 
 
 
ÿþ
ÿ
  þ  z
Tag.decodeccs¢g}|p |j}|D]p}|r>|j|dkr>| ¡}tj|fVqt|tƒrv|jr\tj|fVq‚tj|fV|     |¡qqtj
|fVq|rž| ¡}tj|fVq„dS)a]Yield a sequence of events that can be used to reconstruct the DOM
        for this element.
 
        This lets us recreate the nested structure of this element
        (e.g. when formatting it as a string) without using recursive
        method calls.
 
        This is similar in concept to the SAX API, but it's a simpler
        interface designed for internal use. The events are different
        from SAX and the arguments associated with the events are Tags
        and other Beautiful Soup objects.
 
        :param iterator: An alternate iterator to use when traversing
         the tree.
        r?N) Úself_and_descendantsr@rrxrrGrr4rrsÚSTRING_ELEMENT_EVENT)r r9rrOZnow_closed_tagrrrr÷s 
 
 
zTag._event_streamcCs.d}|r|r|j|}d}|r"d}|||S)a°Add indentation whitespace before and/or after a string.
 
        :param s: The string to amend with whitespace.
        :param indent_level: The indentation level; affects how much
           whitespace goes before the string.
        :param indent_before: Whether or not to add whitespace
           before the string.
        :param indent_after: Whether or not to add whitespace
           (a newline) after the string.
        r-Ú
)Úindent)r rJr1rKr;r<Z space_beforeZ space_afterrrrr7!s 
zTag._indent_stringcCsd}|s d}d}|jr |jd}d}|rÞ| |¡}g}|D]\}    }
|
dkrP|    } npt|
tƒsdt|
tƒrpd |
¡}
n0t|
tƒs„t|
ƒ}
nt|
tƒr |dk    r |
 |¡}
|     |
¡} t|    ƒd| 
| ¡} |  | ¡q:|rÞdd |¡}d} |j rò|j pðd} d|||j|| dS)Nr-ú/rú ú=ú<rä)r Ú
attributesrGr{Útupler[rr)r1Zattribute_valueZquoted_attribute_valuersrZvoid_element_close_prefixr!)r r8rKr3Z closing_slashr Zattribute_stringrEr‹rÚvalÚdecodedrªZvoid_element_closing_slashrrrr57sD
 
 
 
ÿþ
 
 
ÿÿ 
zTag._format_tagr6cCs|dk    o|j p|j|jkS)zˆShould this tag be pretty-printed?
 
        Most of them should, but some (such as <pre> in HTML
        documents) should not.
        N)rúr!)r r1rrrr6hs
üzTag._should_pretty_printcCs*|dkr|jd|dS|j|d|dSdS)a~Pretty-print this PageElement as a string.
 
        :param encoding: The eventual encoding of the string. If this is None,
            a Unicode string will be returned.
        :param formatter: A Formatter object, or a string naming one of
            the standard formatters.
        :return: A Unicode string (if encoding==None) or a bytestring
            (otherwise).
        NT)rKr0)r r0rKrrrÚprettifyvs
z Tag.prettifycCs|j||||jdS)a,Renders the contents of this tag as a Unicode string.
 
        :param indent_level: Each line of the rendering will be
           indented this many levels. (The formatter decides what a
           'level' means in terms of spaces or other characters
           output.) Used internally in recursive calls while
           pretty-printing.
 
        :param eventual_encoding: The tag is destined to be
           encoded into this encoding. decode_contents() is _not_
           responsible for performing that encoding. This information
           is passed in so that it can be substituted in if the
           document contains a <META> tag that mentions the document's
           encoding.
 
        :param formatter: A Formatter object, or a string naming one of
            the standard Formatters.
 
        )r9)r,r)r r1r8rKrrrÚdecode_contents…s
ÿzTag.decode_contentscCs| |||¡}| |¡S)a:Renders the contents of this PageElement as a bytestring.
 
        :param indent_level: Each line of the rendering will be
           indented this many levels. (The formatter decides what a
           'level' means in terms of spaces or other characters
           output.) Used internally in recursive calls while
           pretty-printing.
 
        :param eventual_encoding: The bytestring will be in this encoding.
 
        :param formatter: A Formatter object, or a string naming one of
            the standard Formatters.
 
        :return: A bytestring.
        )rJr1)r r1r0rKrErrrÚencode_contentsžszTag.encode_contentsrcCs|sd}|j||dS)z(Deprecated method for BS3 compatibility.N)r1r0)rK)r r0Z prettyPrintZ indentLevelrrrÚrenderContents´s ÿzTag.renderContentscKs2d}|j||||dfddi|—Ž}|r.|d}|S)aLook in the children of this PageElement and find the first
        PageElement that matches the given criteria.
 
        All find_* methods take a common set of arguments. See the online
        documentation for detailed explanations.
 
        :param name: A filter on tag name.
        :param attrs: A dictionary of filters on attribute values.
        :param recursive: If this is True, find() will perform a
            recursive search of this PageElement's children. Otherwise,
            only the direct children will be considered.
        :param limit: Stop looking after finding this many results.
        :kwargs: A dictionary of filters on attribute values.
        :return: A PageElement.
        :rtype: bs4.element.Tag | bs4.element.NavigableString
        Nr6rŽržrr )r r!r‹rÍrWrŒr r¡rrrr&¾sÿzTag.findc    Ks>|j}|s|j}| dd¡}|j|||||fd|di|—ŽS)aùLook in the children of this PageElement and find all
        PageElements that match the given criteria.
 
        All find_* methods take a common set of arguments. See the online
        documentation for detailed explanations.
 
        :param name: A filter on tag name.
        :param attrs: A dictionary of filters on attribute values.
        :param recursive: If this is True, find_all() will perform a
            recursive search of this PageElement's children. Otherwise,
            only the direct children will be considered.
        :param limit: Stop looking after finding this many results.
        :kwargs: A dictionary of filters on attribute values.
        :return: A ResultSet of PageElements.
        :rtype: bs4.element.ResultSet
        rŽrr6)rÚchildrenrr‘)    r r!r‹rÍrWr”rŒr¸rŽrrrr!Øs ÿÿz Tag.find_allcCs
t|jƒS)zkIterate over all direct children of this PageElement.
 
        :yield: A sequence of PageElements.
        rr rrrrMôsz Tag.childrenccs"|js |V|jD]
}|VqdS)z‰Iterate over this PageElement and its children in a
        breadth-first sequence.
 
        :yield: A sequence of PageElements.
        N)rørr½rrrr=ýs
zTag.self_and_descendantsccs<t|jƒsdS| ¡j}|jd}||k    r8|V|j}q"dS)zˆIterate over all children of this PageElement in a
        breadth-first sequence.
 
        :yield: A sequence of PageElements.
        Nr)rfrErvrB)r ZstopNodeÚcurrentrrrr    s
 
 
zTag.descendantscKs|jj||f|ŽS)aPerform a CSS selection operation on the current element.
 
        :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 kwargs: Keyword arguments to be passed into Soup Sieve's
           soupsieve.select() method.
 
        :return: A Tag.
        :rtype: bs4.element.Tag
        )ÚcssÚ
select_one)r ÚselectorrþrŒrrrrPszTag.select_onecKs|jj|||f|ŽS)aPerform a CSS selection operation on the current element.
 
        This uses the SoupSieve library.
 
        :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 use the prefixes it encountered while
           parsing the document.
 
        :param limit: After finding this number of results, stop looking.
 
        :param kwargs: Keyword arguments to be passed into SoupSieve's
           soupsieve.select() method.
 
        :return: A ResultSet of Tags.
        :rtype: bs4.element.ResultSet
        )rOÚselect)r rQrþr”rŒrrrrR+sz
Tag.selectcCst|ƒS)z,Return an interface to the CSS selector API.rr rrrrOAszTag.csscCs|jS©zDeprecated generator.)rMr rrrÚchildGeneratorGszTag.childGeneratorcCs|jSrS)rr rrrÚrecursiveChildGeneratorKszTag.recursiveChildGeneratorcCstjdtdd| |¡S)z´Deprecated method. This was kind of misleading because has_key()
        (attributes) was different from __in__ (contents).
 
        has_key() is gone in Python 3, anyway.
        z1has_key is deprecated. Use has_attr(key) instead.rr«)r°r±r²rrrrrÚhas_keyOs þz Tag.has_key)NNNNNNNNNNNNNNNN)T)F)N)N)r)N)r6)NrÖ)N)NN)Jr%r&r'r(rÿrZ parserClassrÎrÐrrrZ isSelfClosingrWrrzràrÜr>rÆrUrÝr r    r rhrrrrrrrrrrrr"rÕr)r*r-r.Ú__str__rÈr1r,rÅrrr4r>rr7r5r6rIrJrKrLr&Z    findChildr!ZfindAllZ findChildrenrMr=rrPrRrOrTrUrVrrrrrx§sÌú
u
 
 
 
$
&
 
 
þ
ý
Y
*1
 
þ
þ
ÿ
 
ÿ
 
 
 
 
 
 
rxc@sTeZdZdZdidfdd„Zdd„Zdd„Zdifd    d
„ZeZd d „Z    dd d„Z
dS)r³a&Encapsulates a number of ways of matching a markup element (tag or
    string).
 
    This is primarily used to underpin the find_* methods, but you can
    create one yourself and pass it in as `parse_only` to the
    `BeautifulSoup` constructor, to parse a subset of a large
    document.
    NcKsÌ|dkr*d|kr*| d¡}tjdtdd| |¡|_t|tƒsL||d<d}d|krf|d|d<|d=|r†|r‚| ¡}|     |¡n|}i}t
|  ¡ƒD]\}}| |¡||<q–||_ | |¡|_ |j |_dS)a³Constructor.
 
        The SoupStrainer constructor takes the same arguments passed
        into the find_* methods. See the online documentation for
        detailed explanations.
 
        :param name: A filter on tag name.
        :param attrs: A dictionary of filters on attribute values.
        :param string: A filter for a NavigableString with specific text.
        :kwargs: A dictionary of filters on attribute values.
        NrªzXThe 'text' argument to the SoupStrainer constructor is deprecated. Use 'string' instead.rr«ÚclassÚclass_)rr°r±r²Ú_normalize_search_valuer!rGr÷ÚcopyÚupdater{Úitemsr‹rWrª)r r!r‹rWrŒZnormalized_attrsrrÉrrrrÿfs2 
þ 
   zSoupStrainer.__init__cCsªt|tƒs0t|tƒs0t|dƒs0t|tƒs0|dkr4|St|tƒrH| d¡St|dƒržg}|D]>}t|dƒrˆt|tƒsˆt|tƒsˆ| |¡qZ| | |¡¡qZ|Stt|ƒƒS)Nr5Úutf8r)    rGrrr}ÚboolÚbytesr,rsrZ)r rÉÚ    new_valueÚvrrrrZ–s$ÿÿ
 
 
ÿ z$SoupStrainer._normalize_search_valuecCs |jr |jSd|j|jfSdS)z5A human-readable representation of this SoupStrainer.z%s|%sN)rWr!r‹r rrrrW´szSoupStrainer.__str__c CsHd}d}t|tƒr|}|}t|jtƒr@|r@|js@|j|jkr@dSt|jtƒoVt|tƒ }|jrŠ|sŠ|rt| ||j¡sŠ|s | ||j¡r |rœ| ||¡}nnd}d}t|j     ¡ƒD]V\}}    |sèt
|dƒrÎ|}ni}|D]\}
} | ||
<qÖ|  |¡} | | |    ¡s²d}q
q²|r |r|}n|}|rD|j rD| |j |j ¡sDd}|S)a¾Check whether a Tag with the given name and attributes would
        match this SoupStrainer.
 
        Used prospectively to decide whether to even bother creating a Tag
        object.
 
        :param markup_name: A tag name as found in some markup.
        :param markup_attrs: A dictionary of attributes as found in some markup.
 
        :return: True if the prospective tag would match this SoupStrainer;
            False otherwise.
        NFTr) rGrxr!rr rÚ_matchesr{r‹r]r}rrW) r Z markup_nameZ markup_attrsr¼ÚmarkupZcall_function_with_tag_datar5Zmarkup_attr_maprÚ match_againstÚkrbÚ
attr_valuerrrÚ
search_tag»sX 
 
þÿþ þý ý
 
 
  zSoupStrainer.search_tagcCs²d}t|dƒrDt|ttfƒsD|D] }t|tƒr | |¡r |}q®q njt|tƒrl|jr`|js`|jr®|     |¡}nBt|tƒs€t|tƒr |js®|js®| 
||j¡r®|}nt d|j ƒ‚|S)zâFind all items in `markup` that match this SoupStrainer.
 
        Used by the core _find_all() method, which is ultimately
        called by all find_* methods.
 
        :param markup: A PageElement or a list of them.
        Nrz&I don't know how to match against a %s) r}rGrxrrzr4rWr!r‹rhrcÚ    ExceptionrÔ)r rdr¼r®rrrr4ús(    
ÿ
 
ÿÿzSoupStrainer.searchc    Cszd}t|tƒst|tƒrN|D]}| ||¡rdSq| d |¡|¡rJdSdS|dkr^|dk    St|tƒrp||ƒS|}t|tƒr„|j}| |¡}|dkrœ| St    |dƒr
t|t
ƒs
|s¾t ƒ}|D]B}|j rÒ|}nt |ƒ}||kræqÂqÂ| |¡| |||¡rÂdSqÂdSd}|s(t|t
ƒr(||k}|sDt    |dƒrD| |¡S|svt|tƒrv|jrv| |jd|j|¡S|S)NFTrBrr4r)rGr{rFrcr[rrxr!rZr}rÚsetrÚidÚaddr4r )    r rdreZ already_triedr¹ÚitemZoriginal_markuprr5rrrrc    s` 
 
 
 ÿ
 
ÿþÿzSoupStrainer._matches)N) r%r&r'r(rÿrZrWrhZ    searchTagr4rcrrrrr³\s    0=!r³cs*eZdZdZd‡fdd„    Zdd„Z‡ZS)r´zTA ResultSet is just a list that keeps track of the SoupStrainer
    that created it.rcstt|ƒ |¡||_dS)zlConstructor.
 
        :param source: A SoupStrainer.
        :param result: A list of PageElements.
        N)Úsuperr´rÿÚsource)r ror¹©rÔrrrÿq    szResultSet.__init__cCstd|ƒ‚dS)z7Raise a helpful exception to explain a common code fix.z¡ResultSet object has no attribute '%s'. You're probably treating a list of elements like a single element. Did you call find_all() when you meant to call find()?NrÛrrrrrÕz    sÿzResultSet.__getattr__)r)r%r&r'r(rÿrÕÚ __classcell__rrrprr´n    s    r´).Ú __license__Úcollections.abcrÚ ImportErrorÚeÚ collectionsr;Úsysr°Zbs4.cssrZ bs4.formatterrrrrÈr<Znonwhitespace_reZ whitespace_rerrjr.rrr)r+r2rÅr>rzrÞràrârårçrèrérírîrïrðrñrxr³r{r´rrrrÚ<module>s~ 
 
ô~                 <