g'dZgdZddlZddlmZmZ ddlmZmZm Z m Z m Z m Z m Z e e fZddZddZdd Zd Zej(d ej*j,ZGd d ZdZdZ ddlmZej(dj<Z e dZ#y#e$rddlmZmZm Z m Z m Z m Z e ZYwxYw#e$r ddlmZYMwxYw#e!$re"Z YdZ#ywxYw)z5External interface to the BeautifulSoup HTML parser. ) fromstringparse convert_treeN)etreehtml) BeautifulSoupTagCommentProcessingInstructionNavigableString DeclarationDoctype)rr r r r r c t|||fi|S)aParse a string of HTML data into an Element tree using the BeautifulSoup parser. Returns the root ```` 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 makeelementbsargss E/opt/hc_python/lib64/python3.12/site-packages/lxml/html/soupparser.pyrrs $ { =f ==c vt|ds t|}t|||fi|}tj|S)aYParse 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)hasattropenrr ElementTree)filerrrroots rrr$s; 4 Dz $ { =f =D   T ""rcnt||}|j}|D]}|j||S)aConvert 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 getchildrenremove)beautiful_soup_treerrchildrenchilds rrr3s: ,k :D!H E Orc |t}t|dr d|vrd|d<t|dr d|vrd|d<||fi|}t||}t|dk(r|djdk(r|dSd|_|S) N HTML_ENTITIESconvertEntitiesrDEFAULT_BUILDER_FEATURESfeaturesz html.parserr)rrrlentag)sourcerrrtreers rrrEs% }o. F *(.F$ %}89 V #!.F:   *6 *D { +D 4yA~$q'++/AwDH Krz`(?:\s|[?OPQ?QR'001A!1C1DE  KK ""2AY););;eAaCDkI u% (5LI&H D h  O    Y 'D   D  O  LL #D   0(557N+>:  O $)<<> K**,44G + A Ab0AG !(!:WQr]G  O 0(//N 0sG22H  H c ig  fd} fd d  fd d d|tt fd}|td}|td}|tfd }S) Ncfd}|S)NcBD]}||<j||Sr8)append)handlert convertersordered_node_typestypess raddz5_init_node_converters..converter..adds+ ' 1 "))!,Nrr=)rlrmrjrks` r converterz(_init_node_converters..converters   rc:D]}t||s|cSyr8)rB)noderirjrks rfind_best_converterz2_init_node_converters..find_best_converters&#A$"!!}$$rc t|}|y|||S#t$r|x}t|<Y-wxYwr8)typeKeyError)bs_nodeparentrhrjrqs rr\z+_init_node_converters..convert_nodesY O g/G ?w''  O2Eg2N NGjg/ Os ??ct|trKi}|jD]4\}}t|trdj |}t |||<6|S|Dcic]\}}|t |}}}|Scc}}w)N )rBdictitemslistjoinunescape)bs_attrsattribskvs r map_attrsz(_init_node_converters..map_attrss} h %G (1a& A%a[ ) 3;;($!Qq(1+~(G;.append_texts@ v;! !;;,"4FK%bz4".convert_tags   */i&TG""67<<HC*/i&RGgll7;CE $T%[1&E3'     $s%B B BcVtj|}||j||Sr8)r HtmlCommentrgrurvrs rconvert_commentz._init_node_converters..convert_comments)w'   MM#  rc|jdr|dd}tj|jdd}||j ||S)N?r?rxr*)endswithrr splitrgrs r convert_piz)_init_node_converters..convert_pi sO   C crlG))7==a+@A   MM#  rc.||t|yr8)r})rurvrs r convert_textz+_init_node_converters..convert_texts    1 2rr8)r r0r r r ) rrnrrrrrr\rjrqrrks ` @@@@@@rrFrFsJ ( =sJ ,w $%&  r)name2codepointz&(\w+);c&|syd}t||S)Nrc tt|jdS#t$r|jdcYSwxYw)Nr*r)unichrrgrouprt)ms runescape_entityz!unescape..unescape_entity5s< .45 5 771:  s #AA)handle_entities)rLrs rr}r}1s  ?F 33r)NNr8)$__doc____all__relxmlrrbs4rr r r r r rrD ImportErrorrrrrcompile IGNORECASErarMr0rrF html.entitiesrhtmlentitydefssubrr NameErrorchrr}r=rrrs  2  * +G4 > # $$(RZZ$MM 5 ((Rj^F., "**Z(,, 4G ** *j.-. F 4 s5B1B7CB43B47 CCCC