
    h'                        S r / SQrSSKrSSKJrJr   SSKJrJrJ	r	J
r
JrJrJr  \\4rSS jrSS jrSS	 jrS
 r\R(                  " S\R*                  5      R,                  r " S S5      rS rS r SSKJr  \R(                  " S5      R<                  r \   S r#g! \ a    SSKJrJrJ	r	J
r
JrJr  \r Nf = f! \ a	    SSKJr   NOf = f! \! a    \"r  N>f = f)z5External interface to the BeautifulSoup HTML parser.
)
fromstringparseconvert_tree    N)etreehtml)BeautifulSoupTagCommentProcessingInstructionNavigableStringDeclarationDoctype)r   r	   r
   r   r   r   c                     [        XU40 UD6$ )a  Parse a string of HTML data into an Element tree using the
BeautifulSoup parser.

Returns the root ``<html>`` Element of the tree.

You can pass a different BeautifulSoup parser through the
`beautifulsoup` keyword, and a diffent Element factory function
through the `makeelement` keyword.  By default, the standard
``BeautifulSoup`` class and the default factory of `lxml.html` are
used.
)_parse)databeautifulsoupmakeelementbsargss       F/var/www/html/env/lib/python3.13/site-packages/lxml/html/soupparser.pyr   r      s     ${=f==    c                     [        U S5      (       d  [        U 5      n [        XU40 UD6n[        R                  " U5      $ )aA  Parse a file into an ElemenTree using the BeautifulSoup parser.

You can pass a different BeautifulSoup parser through the
`beautifulsoup` keyword, and a diffent Element factory function
through the `makeelement` keyword.  By default, the standard
``BeautifulSoup`` class and the default factory of `lxml.html` are
used.
read)hasattropenr   r   ElementTree)filer   r   r   roots        r   r   r   $   s<     4  Dz${=f=DT""r   c                 p    [        X5      nUR                  5       nU H  nUR                  U5        M     U$ )zConvert a BeautifulSoup tree to a list of Element trees.

Returns a list instead of a single root Element to support
HTML-like soup with more than one root element.

You can pass a different Element factory through the `makeelement`
keyword.
)_convert_treegetchildrenremove)beautiful_soup_treer   r   childrenchilds        r   r   r   3   s8     ,:D!HE Or   c                    Uc  [         n[        US5      (       a  SU;  a  SUS'   [        US5      (       a  SU;  a  SUS'   U" U 40 UD6n[        XB5      n[        U5      S:X  a  US   R                  S:X  a  US   $ SUl        U$ )	NHTML_ENTITIESconvertEntitiesr   DEFAULT_BUILDER_FEATURESfeatureszhtml.parser   r   )r   r   r   lentag)sourcer   r   r   treer   s         r   r   r   E   s    %}o..F*(.F$%}899V#!.F:*6*D+D
4yA~$q'++/AwDHKr   z`(?:\s|[<!])*DOCTYPE\s*HTML(?:\s+PUBLIC)?(?:\s+(\'[^\']*\'|"[^"]*"))?(?:\s+(\'[^\']*\'|"[^"]*"))?c                        \ rS rSrS rS rSrg)
_PseudoTag^   c                 ,    SU l         / U l        Xl        g )Nr   )nameattrscontents)selfr5   s     r   __init___PseudoTag.__init__`   s    	
 r   c                 6    U R                   R                  5       $ N)r5   __iter__)r6   s    r   r;   _PseudoTag.__iter__e   s    }}%%''r   )r4   r5   r3   N)__name__
__module____qualname____firstlineno__r7   r;   __static_attributes__ r   r   r0   r0   ^   s    !
(r   r0   c                 |   Uc  [         R                  R                  nS =p#S =pE[        U 5       H{  u  pg[	        U[
        5      (       aC  Uc  UnUnUc7  UR                  (       a$  UR                  R                  5       S:X  a  UnMW  MY  M[  M]  Ub  Mb  [	        U[        5      (       d  My  UnM}     Uc  / =pU R                  n
O2U R                  S U nU R                  X#S-    n
U R                  US-   S  n	Ub1  U
R                  U5      nU
S U UR                  -   XS-   S  -   Ul	        O[        U
5      n[        U5      nU" U5      nUn[        U5       H#  nU" U5      nUc  M  UR                  U5        UnM%     UnU	 H#  nU" U5      nUc  M  UR                  U5        UnM%     Uby   UR!                  5       n['        U5      nU(       d   U$ UR)                  5       u  nnUR+                  5       R,                  nU=(       a    USS Ul        U=(       a    USS Ul        U$ ! ["         a    UR$                  n Nf = f)Nr   r*   )r   html_parserr   	enumerate
isinstancer	   r3   lower_DECLARATION_OR_DOCTYPEr5   indexr0   _init_node_convertersreversedaddpreviousaddnextoutput_readyAttributeErrorstring_parse_doctype_declarationgroupsgetroottreedocinfo	public_id
system_url)r"   r   first_element_idxlast_element_idx	html_rootdeclarationiepre_root	post_rootrootsconvert_noderes_rootprev	converteddoctype_stringmatchexternal_idsys_urirU   s                       r   r   r   i   sj   &&22 ,0/""I-.a ($%!  QVV&0H	 1IV  Z3J%K%KK /  !!#,,&//0B1BC#,,->PQ?QR'001A!1C1DE	 KK	""2AY););;eaCDkI	 u%	(5L I&HDh O	 Y'D	   D O	 LL#D	  	0(557N +>:  O $)<<> K**,44G + AAb0AG!(!:WQr]GO  	0(//N	0s   (H" "H;:H;c                   ^ ^^^^	^
^ 0 m/ mUU4S jnUU4S jm	S
UU	4S jjmS m
S mU" [         [        5      UUU U
4S j5       nU" [        5      S 5       nU" [        5      S 5       nU" [        5      U4S	 j5       nT$ )Nc                     >^  UUU 4S jnU$ )Nc                 F   > T H  nU TU'   TR                  U5        M     U $ r:   )append)handlert
convertersordered_node_typestypess     r   add5_init_node_converters.<locals>.converter.<locals>.add   s+     '
1"))!,  Nr   rB   )rq   rr   ro   rp   s   ` r   	converter(_init_node_converters.<locals>.converter   s    	
 
r   c                 F   > T H  n[        X5      (       d  M  TU   s  $    g r:   )rG   )nodern   ro   rp   s     r   find_best_converter2_init_node_converters.<locals>.find_best_converter   s'    #A$""!!}$ $ r   c                    >  T[        U 5         nUc  g U" X5      $ ! [         a    T" U 5      =nT[        U 5      '    N.f = fr:   )typeKeyError)bs_nodeparentrm   ro   rx   s      r   ra   +_init_node_converters.<locals>.convert_node   sW    	O g/G ?w''	  	O2Eg2NNGjg/	Os     A A c                    [        U [        5      (       aP  0 nU R                  5        H8  u  p#[        U[        5      (       a  SR	                  U5      n[        U5      X'   M:     U$ U  VVs0 s H  u  p#U[        U5      _M     nnnU$ s  snnf )N )rG   dictitemslistjoinunescape)bs_attrsattribskvs       r   	map_attrs(_init_node_converters.<locals>.map_attrs   s}    h%%G (a&&A%a[
 )  3;;($!q(1+~(G; <s   +Bc                     [        U 5      S:X  a  U R                  =(       d    SU-   U l        g U S   R                  =(       d    SU-   U S   l        g )Nr    rD   )r+   texttail)r~   r   s     r   append_text*_init_node_converters.<locals>.append_text   s@    v;!!;;,"4FK%bz4"<F2JOr   c                 F  > U R                   nUb1  U(       a  T
" U5      OS n[        R                  " XR                  US9nO"U(       a  T
" U5      O0 nT	" U R                  US9nU  H  n T[	        U5         nUb  U" XT5        M     U$ ! [
         a     Of = fT" XT5        M=  )N)attrib)r4   r   
SubElementr3   r{   r|   )r}   r~   r4   r   resr$   rm   ra   ro   r   r   s          r   convert_tag*_init_node_converters.<locals>.convert_tag   s    */i&TG""6<<HC*/i&RGgll7;CE$T%[1 &E'  
   $s   *B		
BBc                 Z    [         R                  " U 5      nUb  UR                  U5        U$ r:   )r   HtmlCommentrl   r}   r~   r   s      r   convert_comment._init_node_converters.<locals>.convert_comment  s)    w'MM#
r   c                     U R                  S5      (       a  U S S n [        R                  " U R                  SS5      6 nUb  UR	                  U5        U$ )N?rD   r   r*   )endswithr   r   splitrl   r   s      r   
convert_pi)_init_node_converters.<locals>.convert_pi  sR    C   crlG))7==a+@AMM#
r   c                 0   > Ub  T" U[        U 5      5        g r:   )r   )r}   r~   r   s     r   convert_text+_init_node_converters.<locals>.convert_text  s     12r   r:   )r	   r0   r
   r   r   )r   rt   r   r   r   r   r   ra   ro   rx   r   rp   s   `     @@@@@@r   rK   rK      s    J( (	= sJ  , w  $% &   
 r   )name2codepointz&(\w+);c                 .    U (       d  gS n[        X5      $ )Nr   c                      [        [        U R                  S5         5      $ ! [         a    U R                  S5      s $ f = f)Nr*   r   )unichrr   groupr|   )ms    r   unescape_entity!unescape.<locals>.unescape_entity5  s<    	.455 	771:	s    # A A)handle_entities)rQ   r   s     r   r   r   1  s    
 ?33r   )NNr:   )$__doc____all__relxmlr   r   bs4r   r	   r
   r   r   r   r   rI   ImportErrorr   r   r   r   compile
IGNORECASErf   rR   r0   r   rK   html.entitiesr   htmlentitydefssubr   r   	NameErrorchrr   rB   r   r   <module>r      s   2 	 	*    +G4>#$$  ZZ$ MM	 5	 ( (Rj^F.,
 **Z(,,
	4G	  *  *	*j  .-.  Fs5   B 4B; C B87B8;C
	C
CC