Ë
    [RðiÕ'  ã                   ó°  — d Z g d¢ZddlZddlmZmZ 	 ddlmZmZm	Z	m
Z
mZmZmZ eefZdd„Zdd„Zdd	„Zd
„ Z ej(                  dej*                  «      j,                  Z G d„ d«      Zd„ Zd„ Z	 ddlmZ  ej(                  d«      j<                  Z	 e  d„ Z#y# e$ r ddlmZmZm	Z	m
Z
mZmZ eZY Œ‰w xY w# e$ r	 ddlmZ Y ŒMw xY w# e!$ r e"Z Y d„ Z#yw xY w)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                 ó   — t        | ||fi |¤ŽS )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       úO/var/www/html/Extract/venv/lib/python3.12/site-packages/lxml/html/soupparser.pyr   r      s   € ô �$˜ {Ñ=°fÑ=Ð=ó    c                 óv   — t        | d«      st        | «      } t        | ||fi |¤Ž}t        j                  |«      S )aY  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˜Ô Ü�D‹zˆÜ�$˜ {Ñ=°fÑ=€DÜ×Ñ˜TÓ"Ð"r   c                 ón   — t        | |«      }|j                  «       }|D ]  }|j                  |«       Œ |S )a  Convert 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   s?   € ô Ð,¨kÓ:€DØ×ÑÓ!€HØò ˆØ�‰�EÕðà€Or   c                 óì   — |€t         }t        |d«      r	d|vrd|d<   t        |d«      r	d|vrd|d<    || fi |¤Ž}t        ||«      }t        |«      dk(  r|d   j                  dk(  r|d   S d|_        |S )	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Ø˜VÑ#Ø!.ˆF�:ÑÙ˜Ñ* 6Ñ*€DÜ˜˜{Ó+€Dä
ˆ4ƒy�A‚~˜$˜q™'Ÿ+™+¨Ò/Ø�A‰wˆØ€D„HØ€Kr   z`(?:\s|[<!])*DOCTYPE\s*HTML(?:\s+PUBLIC)?(?:\s+(\'[^\']*\'|"[^"]*"))?(?:\s+(\'[^\']*\'|"[^"]*"))?c                   ó   — e Zd Zd„ Zd„ Zy)Ú
_PseudoTagc                 ó.   — d| _         g | _        || _        y )Nr   )ÚnameÚattrsÚcontents)Úselfr4   s     r   Ú__init__z_PseudoTag.__init__`   s   € ØˆŒ	ØˆŒ
Ø ˆ�r   c                 ó6   — | j                   j                  «       S ©N)r4   Ú__iter__)r5   s    r   r9   z_PseudoTag.__iter__e   s   € Ø�}‰}×%Ñ%Ó'Ð'r   N)Ú__name__Ú
__module__Ú__qualname__r6   r9   © r   r   r0   r0   ^   s   „ ò!ó
(r   r0   c                 ó  — |€t         j                  j                  }d x}}d x}}t        | «      D ]b  \  }}t	        |t
        «      r7|€|}|}|�Œ|j                  sŒ,|j                  j                  «       dk(  sŒJ|}ŒM|�ŒPt	        |t        «      sŒa|}Œd |€g x}}	| j                  }
n3| j                  d | }| j                  ||dz    }
| j                  |dz   d  }	|�2|
j                  |«      }|
d | |j                  z   |
|dz   d  z   |_	        nt        |
«      }t        |«      } ||«      }|}t        |«      D ]   } ||«      }|€Œ|j                  |«       |}Œ" |}|	D ]   } ||«      }|€Œ|j                  |«       |}Œ" |�j	 |j!                  «       }t'        |«      }|s	 |S |j)                  «       \  }}|j+                  «       j,                  }|xr |dd |_        |xr |dd |_        |S # t"        $ r |j$                  }Y Œrw xY w)Nr   r*   éÿÿÿÿ)r   Úhtml_parserr   Ú	enumerateÚ
isinstancer	   r2   ÚlowerÚ_DECLARATION_OR_DOCTYPEr4   Ú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_urirP   s                       r   r   r   i   sv  € ØÐÜ×&Ñ&×2Ñ2ˆð ,0Ð/ÐÐ(Ø"Ð"€I�ÜÐ-Ó.ò ‰ˆˆ1Ü�aœÔØ Ð(Ø$%Ð!Ø ÐØÑ  Q§V£V°·±·±³À&Ó0HØ‘	ØÑ ¤Z°Ô3JÕ%KØ‰Kðð Ð Ø!Ð!ˆ�9Ø#×,Ñ,‰à&×/Ñ/Ð0BÐ1BÐCˆØ#×,Ñ,Ð->Ð?OÐPQÑ?QÐRˆØ'×0Ñ0Ð1AÀ!Ñ1CÐ1DÐEˆ	ð Ðà�K‰K˜	Ó"ˆØ" 2 A˜Y¨×);Ñ);Ñ;¸eÀAÀaÁCÀD¸kÑIˆ	Õô ˜uÓ%ˆ	ä(¨Ó5€Lñ ˜IÓ&€HØ€DÜ�hÓò ˆÙ  “Oˆ	ØÑ Ø×Ñ˜YÔ'Ø‰Dð	ð €DØò ˆÙ  “Oˆ	ØÑ Ø�L‰L˜Ô#Ø‰Dð	ð Ðð	0à(×5Ñ5Ó7ˆNô +¨>Ó:ˆÙð ð €Oð $)§<¡<£>Ñ ˆK˜Ø×*Ñ*Ó,×4Ñ4ˆGà +Ò A°¸A¸bÐ0AˆGÔØ!(Ò!:¨W°Q°r¨]ˆGÔà€Oøô ò 	0Ø(×/Ñ/ŠNð	0ús   ÆG2 Ç2H
È	H
c                 óö   ‡ ‡‡‡‡	‡
‡— i Šg Šˆˆfd„}ˆˆfd„Š	d
ˆˆ	fd„	Šd„ Š
d„ Š |t         t        «      ˆˆˆ ˆ
fd„«       } |t        «      d„ «       } |t        «      d„ «       } |t        «      ˆfd	„«       }‰S )Nc                  ó   •‡ — ˆˆˆ fd„}|S )Nc                 óB   •— ‰D ]  }| ‰|<   ‰j                  |«       Œ | S r8   )Úappend)ÚhandlerÚtÚ
convertersÚordered_node_typesÚtypess     €€€r   Úaddz5_init_node_converters.<locals>.converter.<locals>.addÃ   s0   ø€ Øò -�Ø '�
˜1‘Ø"×)Ñ)¨!Õ,ð-ð ˆNr   r=   )rl   rm   rj   rk   s   ` €€r   Ú	converterz(_init_node_converters.<locals>.converterÂ   s   ù€ ö	ð
 ˆ
r   c                 ó:   •— ‰D ]  }t        | |«      sŒ‰|   c S  y r8   )rB   )Únoderi   rj   rk   s     €€r   Úfind_best_converterz2_init_node_converters.<locals>.find_best_converterÊ   s+   ø€ Ø#ò 	%ˆAÜ˜$ Õ"Ø! !‘}Ò$ð	%ð r   c                 ó„   •— 	 ‰t        | «         }|€y  || |«      S # t        $ r  ‰| «      x}‰t        | «      <   Y Œ-w xY wr8   )ÚtypeÚKeyError)Úbs_nodeÚparentrh   rj   rq   s      €€r   r\   z+_init_node_converters.<locals>.convert_nodeÐ   sY   ø€ ð	OØ ¤ g£Ñ/ˆGð ˆ?ØÙ�w Ó'Ð'øô	 ò 	OÙ2EÀgÓ2NÐNˆG�j¤ g£Ó/ð	Oús   ƒ �?¾?c                 ó  — t        | t        «      rKi }| j                  «       D ]4  \  }}t        |t        «      rdj	                  |«      }t        |«      ||<   Œ6 |S | D ��ci c]  \  }}|t        |«      “Œ }}}|S c c}}w )Nú )rB   ÚdictÚitemsÚlistÚjoinÚunescape)Úbs_attrsÚattribsÚkÚvs       r   Ú	map_attrsz(_init_node_converters.<locals>.map_attrsÚ   s�   € Ü�h¤Ô%ØˆGØ Ÿ™Ó(ò )‘��1Ü˜a¤Ô&ØŸ™ ›�AÜ% a›[�˜’
ð)ð ˆð 3;×;©$¨!¨Q�qœ( 1›+‘~Ð;ˆGÑ;Øˆùó <s   Á!A<c                 óŽ   — t        | «      dk(  r| j                  xs d|z   | _        y | d   j                  xs d|z   | d   _        y )Nr   Ú r?   )r+   ÚtextÚtail)rv   r…   s     r   Úappend_textz*_init_node_converters.<locals>.append_textå   s@   € Üˆv‹;˜!ÒØ!Ÿ;™;Ò,¨"°Ñ4ˆF�Kà% b™zŸ™Ò4°"¸Ñ<ˆF�2‰J�Or   c                 ó6  •— | j                   }|�/|r ‰
|«      nd }t        j                  || j                  |¬«      }n |r ‰
|«      ni } ‰	| j                  |¬«      }| D ]  }	 ‰t	        |«         }|�	 |||«       Œ |S # t
        $ r Y nw xY w ‰||«       Œ:)N)Úattrib)r3   r   Ú
SubElementr2   rs   rt   )ru   rv   r3   r   Úresr$   rh   r\   rj   r   r‚   s          €€€€r   Úconvert_tagz*_init_node_converters.<locals>.convert_tagí   s´   ø€ à—‘ˆØÐÙ*/‘i Ô&°TˆGÜ×"Ñ" 6¨7¯<©<ÀÔH‰Cá*/‘i Ô&°RˆGÙ˜gŸl™l°7Ô;ˆCàò 
	%ˆEðØ$¤T¨%£[Ñ1�ð Ð&Ù˜E 3Ô'Øð
	%ð ˆ
øô ò Ùðúñ ˜ Õ$s   Á%BÂ	BÂBc                 óV   — t        j                  | «      }|�|j                  |«       |S r8   )r   ÚHtmlCommentrg   ©ru   rv   r‹   s      r   Úconvert_commentz._init_node_converters.<locals>.convert_comment  s)   € ä×Ñ˜wÓ'ˆØÐØ�M‰M˜#ÔØˆ
r   c                 óœ   — | j                  d«      r| d d } t        j                  | j                  dd«      Ž }|�|j	                  |«       |S )Nú?r?   rx   r*   )Úendswithr   r   Úsplitrg   r�   s      r   Ú
convert_piz)_init_node_converters.<locals>.convert_pi  sO   € à×Ñ˜CÔ ð ˜c˜r�lˆGÜ×)Ñ)¨7¯=©=¸¸aÓ+@ÐAˆØÐØ�M‰M˜#ÔØˆ
r   c                 ó.   •— |� ‰|t        | «      «       y r8   )r}   )ru   rv   r‡   s     €r   Úconvert_textz+_init_node_converters.<locals>.convert_text  s   ø€ àÐÙ˜¤¨Ó 1Ô2Ør   r8   )r	   r0   r
   r   r   )r   rn   rŒ   r�   r•   r—   r‡   r\   rj   rq   r‚   rk   s   `     @@@@@@r   rF   rF   ¾   s–   þ€ Ø€JØÐõõö(ò	ò=ñ Œs”JÓöó  ðñ, ŒwÓñó ðñ Ô$Ó%ñó &ðñ ŒÓóó  ðð
 Ðr   )Úname2codepointz&(\w+);c                 ó&   — | syd„ }t        || «      S )Nr„   c                 ó†   — 	 t        t        | j                  d«         «      S # t        $ r | j                  d«      cY S w xY w)Nr*   r   )Úunichrr˜   Úgrouprt   )Úms    r   Úunescape_entityz!unescape.<locals>.unescape_entity5  s<   € ð	Üœ.¨¯©°«Ñ4Ó5Ð5øÜò 	Ø—7‘7˜1“:Òð	ús   ‚ # £A ¿A )Úhandle_entities)rL   rž   s     r   r}   r}   1  s   € ÙØòô
 ˜?¨FÓ3Ð3r   )NNr8   )$Ú__doc__Ú__all__ÚreÚlxmlr   r   Úbs4r   r	   r
   r   r   r   r   rD   ÚImportErrorr   r   r   r   ÚcompileÚ
IGNORECASEra   rM   r0   r   rF   Úhtml.entitiesr˜   ÚhtmlentitydefsÚsubrŸ   r›   Ú	NameErrorÚchrr}   r=   r   r   ú<module>r­      s  ðñò 2€ã 	ß ð	*÷÷ ñ ð  +¨GÐ4Ðó>ó#óò$ð$ (˜RŸZ™Zð$ð ‡M�Mó	÷ ‘5ð	 ÷(ñ (òRòj^ðF.Ý,ð
 �"—*‘*˜ZÓ(×,Ñ,€ðÙ
ó	4øðG	 ò *÷÷ ð *Òð	*ûðj ò .ß-ð.ûð ò à�Fó	4ðús5   ”B Á1B7 ÂC ÂB4Â3B4Â7CÃCÃCÃC