MpjmUddlmZdZddlZddlZddlZddlmZddlm Z m Z m Z ddl m Z mZmZddlmZddlmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%dd l&m'Z'm(Z(erBdd l)m*Z*dd l+m,Z,dd l-m.Z.dd l m/Z/m0Z0ddl1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;mZ>m?Z?m@Z@mAZAmBZBmCZCe#e!dee!dfZDdeEd<e#dZFdeEd<eeFZGdeEd<eHdZIejdZKdeEd<dUdZLdZMdeEd<ejdZNdeEd<eOgd ZPd!eEd"<Gd#d$eQZRGd%d&eQZSGd'd(eSZTGd)d*eeQZUGd+d,eeefZVGd-d.eVZWGd/d0eVZXGd1d2eSZYGd3d4eZZ[Gd5deQe[Z\Gd6d7e\Z]Gd8d9e]Z^Gd:d;e]Z_Gd<d=e_Z`Gd>d?e]ZaGd@dAe]ZbGdBdCe]ZcGdDdEe\ZdGdFdGe\ZeGdHdIe\ZfGdJdKe\ZgGdLdMe\ZhGdNdOe[Zie"dPe[QZjGdRdSeejeejZkddTl-mlZly)V) annotationsMITNCSS) _deprecated_deprecated_alias_deprecated_function_alias) Formatter HTMLFormatter XMLFormatter)!AttributeResemblesVariableWarning)AnyCallableDictGenericIterableIteratorListMappingMutableSequenceOptionalPatternSet TYPE_CHECKINGTupleTypeTypeVarUnioncastoverload)Self TypeAlias BeautifulSoup) TreeBuilder ElementFilter)_EntitySubstitutionFunction_FormatterOrName)_AtMostOneElement_AtMostOneNavigableString _AtMostOneTag_AttributeValue_AttributeValues _Encoding_InsertableElement _OneElement _QueryResults_RawAttributeValue_RawAttributeValues_RawOrProcessedAttributeValues_SomeNavigableStrings _SomeTags_StrainableAttribute_StrainableAttributes_StrainableElement_StrainableStringNavigableStringr"_OneOrMoreStringTypes)r:r'_FindMethodName_OptionalFindMethodNamezYThe {name} attribute was deprecated in version 4.7.0. If you need it, make your own copy.) whitespace_rez\s+ Pattern[str]_deprecated_whitespace_restrc|tvrEt|}tj|j|tdt d|St dtd|)Nname stacklevel _deprecated_zmodule z has no attribute )_deprecated_nameswarningswarnformatDeprecationWarningglobalsAttributeError__name__)rFmessages Y/mnt/ssd/data/Dropbox/adrian/scripts/msg_venv/lib/python3.12/site-packages/bs4/element.py __getattr__rU^s_   #D) gnn$n/1CPQRy<v.// 78,.@I JJutf-8DEFAULT_OUTPUT_ENCODINGz\S+nonwhitespace_re) idnambcsoempalmospunycoderaw_unicode_escape undefinedunicode_escapezraw-unicode-escapezunicode-escapez string-escape string_escapezSet[_Encoding]PYTHON_SPECIFIC_ENCODINGScLeZdZUdZded<ded<ded< d d dZy) NamespacedAttributezA namespaced attribute (e.g. the 'xml:lang' in 'xml:lang="en"') which remembers the namespace prefix ('xml') and the name ('lang') that were used to create it. Optional[str]prefixrF namespaceNc|sd}|stj||}n5|stj||}ntj||dz|z}||_||_||_|S)N:)rC__new__rgrFrh)clsrgrFrhobjs rTrkzNamespacedAttribute.__new__sg D++c6*C++c4(C++c6C<$#67C !  rVNN)rgrfrFrfrhrfreturnr!)rR __module__ __qualname____doc____annotations__rkrVrTreresN   ##' !   rVrec$eZdZUdZded<ddZy)%AttributeValueWithCharsetSubstitutionaAn abstract class standing in for a character encoding specified inside an HTML ```` tag. Subclasses exist for each place such a character encoding might be found: either inside the ``charset`` attribute (`CharsetMetaAttributeValue`) or inside the ``content`` attribute (`ContentMetaAttributeValue`) This allows Beautiful Soup to replace that part of the HTML file with a different encoding when ouputting a tree as a string. rCoriginal_valuect)zDo whatever's necessary in this implementation-specific portion an HTML document to substitute in a specific encoding. NotImplementedErrorselfeventual_encodings rTsubstitute_encodingz9AttributeValueWithCharsetSubstitution.substitute_encodings "##rVN)r}rCrorC)rRrprqrrrsr~rtrVrTrvrvs $rVrvc"eZdZdZddZdddZy)CharsetMetaAttributeValueazA generic stand-in for the value of a ```` tag's ``charset`` attribute. When Beautiful Soup parses the markup ````, the value of the ``charset`` attribute will become one of these objects. If the document is later encoded to an encoding other than UTF-8, its ```` tag will mention the new encoding instead of ``utf8``. c@tj||}||_|SN)rCrkrwrlrwrms rTrkz!CharsetMetaAttributeValue.__new__s!kk#~.+ rVc|tvry|S)zWhen an HTML document is being encoded to a given encoding, the value of a ```` tag's ``charset`` becomes the name of the encoding. )rcr{s rTr~z-CharsetMetaAttributeValue.substitute_encodings  9 9  rVNrwrCror!rWr}r/rorC)rRrprqrrrkr~rtrVrTrrs!rVrceZdZdZy)AttributeValueLista-Class for the list used to hold the values of attributes which have multiple values (such as HTML's 'class'). It's just a regular list, but you can subclass it and pass it in to the TreeBuilder constructor as attribute_value_list_class, to have your subclass instantiated instead. NrRrprqrrrtrVrTrrrVrceZdZdZy) AttributeDictzSuperclass for the dictionary used to hold a tag's attributes. You can use this, but it's just a regular dict with no special logic. NrrtrVrTrrsrVrc$eZdZdZdfd ZxZS)XMLAttributeDictzyA dictionary for holding a Tag's attributes, which processes incoming values for consistency with the HTML spec. c|d}t|trn!t|ttfr t |}t |||y)zSet an attribute value, possibly modifying it to comply with the XML spec. This just means converting common non-string values to strings: XML attributes may have "any literal string as a value." Nr) isinstanceboolintfloatrCsuper __setitem__r|keyvalue __class__s rTrzXMLAttributeDict.__setitem__sF =E eT "  U| , JE C'rVrrCrrroNonerRrprqrrr __classcell__rs@rTrrs((rVrc$eZdZdZdfd ZxZS)HTMLAttributeDictaA dictionary for holding a Tag's attributes, which processes incoming values for consistency with the HTML spec, which says 'Attribute values are a mixture of text and character references...' Basically, this means converting common non-string values into strings, like XMLAttributeDict, though HTML also has some rules around boolean attributes that XML doesn't have. c|dvr||vr||=yt|tr t|tr |j}n$|}n!t|tt fr t |}t|!||y)z\Set an attribute value, possibly modifying it to comply with the HTML spec, )FNN) rrrerFrrrCrrrs rTrzHTMLAttributeDict.__setitem__sm M !d{I  eT "#23 U| ,JE C'rVrrrs@rTrrs((rVrcheZdZUdZej dej Zded<ddZ d d dZ y) ContentMetaAttributeValueaA generic stand-in for the value of a ```` tag's ``content`` attribute. When Beautiful Soup parses the markup: ```` The value of the ``content`` attribute will become one of these objects. If the document is later encoded to an encoding other than UTF-8, its ```` tag will mention the new encoding instead of ``utf8``. z((^|;)\s*charset=)([^;]*)rA CHARSET_REcv|jj|tj||}||_|Sr)rsearchrCrkrwrs rTrkz!ContentMetaAttributeValue.__new__Ps1 n-kk#~.+ rVctvr&|jjd|jSdfd }|jj||jS)zWhen an HTML document is being encoded to a given encoding, the value of the ``charset=`` in a ```` tag's ``content`` becomes the name of the encoding. rc,|jdzS)N)group)matchr}s rTrewritez>ContentMetaAttributeValue.substitute_encoding..rewrite^s;;q>$55 5rV)rz re.Match[str]rorC)rcrsubrw)r|r}rs ` rTr~z-ContentMetaAttributeValue.substitute_encodingVsO  9 9??&&r4+>+>? ? 6""7D,?,?@@rVNrrr) rRrprqrrrecompileMrrsrkr~rtrVrTrr>s0  *rzz*FMJ M ArVrc eZdZUdZdZded<ded<ded<d ed <d ed <d ed <d ed <dZded< d~ ddZddZ ddZ e ddZ e dd dZ e dd dZdddZddZeZded<def ddZe ddZddef ddZeZe ddZdd Zed!d"dZdd#Zddd$Zdd%Z d dd&Ze d'd(dZdd)Z dd*Z! d dd+Z"d dd,Z#e dd-Z$e dd.Z%e& d dd/Z'e& d dd0Z' d dd1Z'ed2d3dZ(e& ddd4 dd5Z)e& d dd6Z) d dd7Z)ed8d9dZ*e& d dd:Z+e& d dd;Z+ d dd<Z+ed=d>dZ,e& ddd4 dd?Z-e& d dd@Z- d ddAZ-edBdCdZ.edDdCdEZ/e& d ddFZ0e& d ddGZ0 d ddHZ0edIdJdEZ1e& ddd4 ddKZ2e& d ddLZ2 d ddMZ2edNdOdZ3edPdOdEZ4e& d ddQZ5e& d ddRZ5 d ddSZ5edTdUdZ6e& ddd4 ddVZ7e& d ddWZ7 d ddXZ7edYdZdZ8ed[dZdEZ9 d dd\Z:ed]d^dZ; d dd_Z<ed`dadZ=edbdadEZ>e ddcZ?e dddZ@ ddeZAe ddfZB ddgZCe ddhZDe ddiZEe ddjZFe ddkZGe ddlZHe ddmZIe ddnZJe ddoZKe ddpZLe ddqZMddrZNe ddsZOePdtddduZQePdvdddwZRePdxdddyZSePdzddd{ZTePd|ddd}ZUy) PageElementazAn abstract class representing a single element in the parse tree. `NavigableString`, `Tag`, etc. are all subclasses of `PageElement`. For this reason you'll see a lot of methods that return `PageElement`, but you'll never see an actual `PageElement` object. For the most part you can think of `PageElement` as meaning "a `Tag` or a `NavigableString`." NOptional[bool] known_xmlr _decomposed Optional[Tag]parentr* next_elementprevious_element next_siblingprevious_siblingFhiddenc||_||_|j||j_||_|j||j_||_|j||j_|;|j/|jj r|jj d}||_|j||j_yy)aISets 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 after 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)rrrrrcontents)r|rrrrrs rTsetupzPageElement.setups2 0  ,15D ! ! .(    (15D   .(    (15D   .  $ ' $$#{{33B7  0  ,15D ! ! . -rVcr||St|ts|j|}|j|}|S)zFormat 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. )rr formatter_for_name substitute)r|s formatteroutputs rT format_stringzPageElement.format_strings>  H)Y/// :I%%a( rVct|tr|S|jrt}tj}nt }t j}t |r ||S||S)aLook 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 `bs4.formatter.XMLFormatter` or `bs4.formatter.HTMLFormatter`), or a string (used to look up an `bs4.formatter.XMLFormatter` or `bs4.formatter.HTMLFormatter` in the appropriate registry. )entity_substitution)rr _is_xmlr REGISTRYr callable)r|formatter_namecregistrys rTrzPageElement.formatter_for_names[ ni 0! ! <<A#,,HA$--H N #8 8''rVc|j |jS|j t|ddS|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. is_xmlF)rrgetattrrr|s rTrzPageElement._is_xmlsG >> %>> ! ;; 451 1{{"""rV nextSibling4.0.0previousSiblingctrryr|memo recursives rT __deepcopy__zPageElement.__deepcopy__s !##rVc$|jiS)zA copy of a PageElement can only be a deep copy, because only one PageElement can occupy a given place in a parse tree. )rrs rT__copy__zPageElement.__copy__s  $$rVIterable[type[NavigableString]]defaultct)zYield all strings of certain classes, possibly stripping them. This is implemented differently in `Tag` and `NavigableString`. ry)r|striptypess rT _all_stringszPageElement._all_stringss "##rVc#@K|jdD]}|yw)zYield all interesting strings in this PageElement, stripping them first. See `Tag` for information on which strings are considered interesting in a given context. TNr)r|strings rTstripped_stringszPageElement.stripped_strings s'''- FL srcl|j|j||Dcgc]}|c}Scc}w)aGet 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. )r)joinr)r| separatorrrrs rTget_textzPageElement.get_texts1.~~$*;*;E*;*OPQqPQQPs 1c"|jSr)rrs rTtextzPageElement.text1s}}rVcbj tdt|dk(r |durStfd|Dr tdj}jj }j |t ||D]\}}|j||S)zReplace this `PageElement` with one or more other elements, objects, keeping the rest of the tree the same. :return: This `PageElement`, no longer part of the tree. z^Cannot replace one element with another when the element to be replaced is not part of a tree.rrc3:K|]}|juywrr.0xr|s rT z+PageElement.replace_with..Cs.AqDKK.sz%Cannot replace a Tag with its parent. _self_index)start)r ValueErrorlenanyindexextract enumerateinsert)r|args old_parentmy_indexidx replace_withs` rTrzPageElement.replace_with5s ;; @  t9>d1goK .. .DE E[[ ;;$$T*  *!*4x!@ 1 C   c< 0 1 rV replaceWithrcJ|j|}|j||S)zWrap this `PageElement` inside a `Tag`. :return: ``wrap_inside``, occupying the position in the tree that used to be occupied by this object, and with this object now inside it. )rappend)r| wrap_insidemes rTwrapzPageElement.wrapNs(   { +2rVc|j4||jj|}|jj|=|j}t t |}|j }|j|j|ur||j_|||jur|j|_d|_d|_d|_|j3|j|jur|j|j_ |j3|j|jur|j|j_dx|_|_ |S)a'Destructively 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: this `PageElement`, no longer part of the tree. N) rrr_last_descendantrrrrrr)r|r last_childrs rTrzPageElement.extractXs@ ;; """kk//5  $$[1 **, +z2 !..  ,$$L85A%%2  # D->>151B1BD ! ! .    )!!)>)>>151F1FD   .488 1 rVc|j|}d}|Q|j}|jjt |t rd|_g|_d|_|}|Pyy)aRecursively destroys this `PageElement` and its children. The 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 `PageElement.decomposed` property. NrT) rr__dict__clearrTagrFrr)r|enext_ups rT decomposezPageElement.decomposes` #%)mnnG JJ   !S!  AMAmrVc|r#|j|jj}nJ|}t|tr8|jr,|jd}t|tr |jr,|s||urd}|S)apFinds the last element beneath this object to be parsed. Special note to help you figure things out if your type checking is tripped up by the fact that this method returns _AtMostOneElement instead of PageElement: the only time this method returns None is if `accept_self` is False and the `PageElement` has no children--either it's a NavigableString or an empty Tag. :param is_initialized: Has `PageElement.setup` been called on this `PageElement` yet? :param accept_self: Is ``self`` an acceptable answer to the question? Nr)rrrrr)r|is_initialized accept_selfrs rTr zPageElement._last_descendantss$ d//;**;;JJZ-*2E2E'004 Z-*2E2EzT1JrV_lastRecursiveChildr c.j}| tdtfd|Dr tdg}|D]T}t|tr|j |j }|j|j||V|S)aVMakes the given element(s) the immediate predecessor of this one. All the elements will have the same `PageElement.parent` as this one, and the given elements will occur immediately before this one. :param args: One or more PageElements. :return The list of PageElements that were inserted. z2Element has no parent, so 'before' has no meaning.c3&K|]}|u ywrrtrs rTrz,PageElement.insert_before..'QqDy'z&Can't insert an element before itself. rrrrrrrextendr)r|rrresults predecessorrs` rT insert_beforezPageElement.insert_befores >QR R '$' 'EF F%' >K+{3##%LL&E NN6== < =  >rVcHj}| tdtfd|Dr tdd}g}|D]_}t|tr|j |j }|j|j|dz|z||dz }a|S)aOMakes the given element(s) the immediate successor of this one. The elements will have the same `PageElement.parent` as this one, and the given elements will occur immediately after this one. :param args: One or more PageElements. :return The list of PageElements that were inserted. z1Element has no parent, so 'after' has no meaning.c3&K|]}|u ywrrtrs rTrz+PageElement.insert_after..rrz%Can't insert an element after itself.rrr)r|rroffsetr  successorrs` rT insert_afterzPageElement.insert_afters >PQ Q '$' 'DE E%' I)[1!!#LL&E NN6==V);YG H aKF rVc f|j} | td| j|||||||fi|S)zVCreate a new Tag associated with the same BeautifulSoup object as this PageElement is.zLCannot call new_tag on a PageElement not contained in a BeautifulSoup object) _root_objectrnew_tag) r|rFrhnsprefixattrs sourceline sourceposrkwattrsroots rTr*zPageElement.new_tagsD   <kl lt||D)Xuj)U[g_fggrVcX|j}| td|j||S)zbCreate a new NavigableString associated with the same BeautifulSoup object as this PageElement is.zOCannot call new_string on a PageElement not contained in a BeautifulSoup object)r)r new_string)r|rsubclassr0s rTr2zPageElement.new_string s1   <no oq(++rVc|j}|'|js|j}| |js||Std|S)z\Find the BeautifulSoup object used to create this PageElement, assuming it's still attached.r$)r_is_rootr)r|rs rTr)zPageElement._root_objectsG ${{ ]]F  >MOV,,rVcy)z[No, this object is not the root of its parse tree; only a BeautifulSoup object can be that.Frtrs rTr5zPageElement._is_rootsrVc yrrtr|rFr,rkwargss rT find_nextzPageElement.find_next" rVc yrrtr8s rTr:zPageElement.find_next. rVc B|j|j|||fi|S)aFind 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: Additional filters on attribute values. :param string: A filter for a NavigableString with specific text. :kwargs: Additional filters on attribute values. ) _find_one find_all_nextr8s rTr:zPageElement.find_next8s&$t~~d00$vPPPrVfindNextr:limitc yrrtr|rFr,rrCr9s rTr@zPageElement.find_all_nextO rVc yrrtrEs rTr@zPageElement.find_all_next\r;rVc D|j|||||jfi|S)a4Find all `PageElement` objects 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: Additional filters on attribute values. :param string: A filter for a NavigableString with specific text. :param limit: Stop looking after finding this many results. :kwargs: Additional filters on attribute values. ) _find_all next_elementsrEs rTr@zPageElement.find_all_nextg6(t~~            rV findAllNextr@c yrrtr8s rTfind_next_siblingzPageElement.find_next_siblingr;rVc yrrtr8s rTrNzPageElement.find_next_siblingr=rVc B|j|j|||fi|S)aFind 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: Additional filters on attribute values. :param string: A filter for a `NavigableString` with specific text. :kwargs: Additional filters on attribute values. )r?find_next_siblingsr8s rTrNzPageElement.find_next_siblings&$t~~d55tUFUfUUrVfindNextSiblingrNc yrrtrEs rTrQzPageElement.find_next_siblingsrFrVc yrrtrEs rTrQzPageElement.find_next_siblingsr;rVc D|j|||||jfi|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: Additional filters on attribute values. :param string: A filter for a `NavigableString` with specific text. :param limit: Stop looking after finding this many results. :kwargs: Additional filters on attribute values. )rI next_siblingsrEs rTrQzPageElement.find_next_siblingsrKrVfindNextSiblingsrQfetchNextSiblings3.0.0c yrrtr8s rT find_previouszPageElement.find_previousr;rVc yrrtr8s rTr[zPageElement.find_previousr=rVc B|j|j|||fi|S)aLook 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: Additional filters on attribute values. :param string: A filter for a `NavigableString` with specific text. :kwargs: Additional filters on attribute values. )r?find_all_previousr8s rTr[zPageElement.find_previous s&$t~~d44dE6TVTTrV findPreviousr[c yrrtrEs rTr^zPageElement.find_all_previous rFrVc yrrtrEs rTr^zPageElement.find_all_previous-r;rVc D|j|||||jfi|S)a0Look backwards in the document from this `PageElement` and find all `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: Additional filters on attribute values. :param string: A filter for a `NavigableString` with specific text. :param limit: Stop looking after finding this many results. :kwargs: Additional filters on attribute values. )rIprevious_elementsrEs rTr^zPageElement.find_all_previous86(t~~      " "     rVfindAllPreviousr^fetchAllPreviousc yrrtr8s rTfind_previous_siblingz!PageElement.find_previous_sibling]r;rVc yrrtr8s rTrhz!PageElement.find_previous_siblingir=rVc B|j|j|||fi|S)aReturns 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: Additional filters on attribute values. :param string: A filter for a `NavigableString` with specific text. :kwargs: Additional filters on attribute values. )r?find_previous_siblingsr8s rTrhz!PageElement.find_previous_siblingss.$t~~  ' 'uf @F  rVfindPreviousSiblingrhc yrrtrEs rTrkz"PageElement.find_previous_siblingsrFrVc yrrtrEs rTrkz"PageElement.find_previous_siblingsr;rVc D|j|||||jfi|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: Additional filters on attribute values. :param string: A filter for a NavigableString with specific text. :param limit: Stop looking after finding this many results. :kwargs: Additional filters on attribute values. )rIprevious_siblingsrEs rTrkz"PageElement.find_previous_siblingsrdrVfindPreviousSiblingsrkfetchPreviousSiblingsc Bd}|j||dfi|}|r|d}|S)aFind 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: Additional filters on attribute values. :param self: Whether the PageElement itself should be considered as one of its 'parents'. :kwargs: Additional filters on attribute values. Nrr) find_parents)r|rFr,r9rr s rT find_parentzPageElement.find_parents=( #$## % $   ArV findParentrvc r|j}ttt|j||d||fi|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: Additional filters on attribute values. :param limit: Stop looking after finding this many results. :kwargs: Additional filters on attribute values. N)parentsr ResultSetrrI)r|rFr,rCr9iterators rTrtzPageElement.find_parentssB"<<IcNNDNN %uh% 28%   rV findParentsrt fetchParentsc|jS)z?The `PageElement`, if any, that was parsed just after this one.rrs rTnextzPageElement.nexts   rVc|jS)z@The `PageElement`, if any, that was parsed just before this one.rrs rTpreviouszPageElement.previous$$$rVc 0d}||||dfi|}|r|d}|S)Nrrrt)r|methodrFr,rr9rur s rTr?zPageElement._find_ones/ $!'eVQ!I&!I  ArVcd}tjdD]U}|jB|jj,|jjj dddk7r|S|dz }W|S)zdFind the appropriate stack level to use when issuing a warning relating to one of the find* methods.r)contextrRrz bs4.elementr)inspectstackframe f_globalsget)r|rI frameinfos rT_warning_stack_levelz PageElement._warning_stack_level!sv   q1 I+OO--9OO--11*bA]R !OJ   rVc <|;d|vr7|jd}tjdt|jd|vrBtjt j tddzt |jdd lm }t||r|}nt|||fi|}||s|s|s|d us|,|D cgc]} t| ts| } } t|| St|tr|jd d k(r|j!d d \} } nd} |} g} |D]U} t| ts| j"|k(s"| j"| k(s3| | j$| k(sE| j'| Wt|| S|j)||Scc} w) z8Iterates over a generator looking for things that match.NrzOThe 'text' argument to find()-type methods is deprecated. Use 'string' instead.rH_classclass_)original autocorrectrr&Trjr)poprLrMrOrr MESSAGEdict bs4.filterr'r SoupStrainerrrzrCcountsplitrFrgrfind_all) r|rFr,rrC generatorr9r'matcherelementresultrg local_names rTrIzPageElement._find_all:s >f.ZZ'F MMa"44  v  MM199% ( 244  - dM *G"4A&AG >%ft|t|1:WgjRU>V'WW &11D#&::c?a'*.C);&FJ!F!%J(/G%gs3 ||t+ 2#^w~~/G g./!&11 511-Xs 9FFc#TK|j}||j}||}|yyw)z1All PageElements that were parsed after this one.Nrr|ir&s rTrJzPageElement.next_elements}s2   mIGAm#((c8|j|jS)zBThis PageElement, then all PageElements that were parsed after it.) _self_andrJrs rTself_and_next_elementsz"PageElement.self_and_next_elements~~d0011rVc#TK|j}||j}||}|yyw)zVAll PageElements that are siblings of this one but were parsed later. N)rrs rTrVzPageElement.next_siblingss2   mIGAmrc8|j|jS)z+This PageElement, then all of its siblings.)rrVrs rTself_and_next_siblingsz"PageElement.self_and_next_siblingsrrVc#TK|j}||j}||}|yyw)zhAll PageElements that were parsed before this one. :yield: A sequence of PageElements. Nrrs rTrczPageElement.previous_elementss4  ! !m**IGAmrc8|j|jS)zEThis PageElement, then all elements that were parsed earlier.)rrcrs rTself_and_previous_elementsz&PageElement.self_and_previous_elements~~d4455rVc#TK|j}||j}||}|yyw)zAll PageElements that are siblings of this one but were parsed earlier. :yield: A sequence of PageElements. N)rrs rTrpzPageElement.previous_siblingss4  ! !m**IGAmrc8|j|jS)zLThis PageElement, then all of its siblings that were parsed earlier.)rrprs rTself_and_previous_siblingsz&PageElement.self_and_previous_siblingsrrVc#TK|j}||j}||}|yyw)zAll elements that are parents of this PageElement. :yield: A sequence of Tags, ending with a BeautifulSoup object. Nrrs rTryzPageElement.parentss0 KKmIGAmrc8|j|jS)zThis element, then all of its parents. :yield: A sequence of PageElements, ending with a BeautifulSoup object. )rryrs rTself_and_parentszPageElement.self_and_parentss ~~dll++rVc#BK|js||D]}|yw)zmModify a generator by yielding this element, then everything yielded by the other generator. N)r)r|other_generatorrs rTrzPageElement._self_ands({{J  AG sc$t|ddxsdS)z0Check whether a PageElement has been decomposed.rF)rrs rT decomposedzPageElement.decomposedst]E2;e;rVrJc|jSz:meta private:)rJrs rT nextGeneratorzPageElement.nextGenerator!!!rVrVc|jSr)rVrs rTnextSiblingGeneratorz PageElement.nextSiblingGeneratorrrVrcc|jSr)rcrs rTpreviousGeneratorzPageElement.previousGenerator%%%rVrpc|jSr)rprs rTpreviousSiblingGeneratorz$PageElement.previousSiblingGeneratorrrVryc|jSr)ryrs rTparentGeneratorzPageElement.parentGenerators||rV)NNNNN) rrrr*rr*rr*rr*ror)rrCrOptional[_FormatterOrName]rorC)rz4Union[_FormatterOrName, _EntitySubstitutionFunction]ror rorFrzDict[Any, Any]rrror!ror!)rrrrro Iterator[str]ror)rrCrrrzIterable[Type[NavigableString]]rorCrorC)rr0ror!)r rrorr)r Optional[int]ror!ror)TT)rrrrror*)rr0roList[PageElement])NNNNNN)rFrCrhrfr+rfr,zOptional[_RawAttributeValues]r-rr.rrrfr/r3ror)rrCr3zOptional[Type[NavigableString]]ror<)roOptional[BeautifulSoup]rn) rFrr,rrr;r9r8ror+)NNN) rFr?r,Optional[_StrainableAttributes]rrr9r8ror,) rFr?r,rrOptional[_StrainableString]r9r8roBUnion[_AtMostOneTag, _AtMostOneNavigableString, _AtMostOneElement]) rFrr,rrr;rCrr9r8ror6)NNNN) rFr?r,rrrrCrr9r8ror7) rFr?r,rrrrCrr9r8ro6Union[_SomeTags, _SomeNavigableStrings, _QueryResults])rFr?r,rr9r8ror,) rFr?r,rrCrr9r8ror7)ror*) rrrFr?r,rrrr9r8ror*ror)rFr?r,rrrrCrrIterator[PageElement]r9r8ror2ror)roz Iterator[Tag])rrror)VrRrprqrrrrsrrrrpropertyrrrrrrtuplerrrrgetTextrrr rr rrr rr"r'r*r2r)r5r r:rAr@rLrNrRrQrWrXr[r_r^rerfrhrlrkrqrrrvrwrtr|r}rrr?rrIrJrrVrrcrrprryrrrrrrrrrrtrVrTrrds !%I~$ ##''##''FD!%.2*..2*. 0606,06( 06 , 06 ( 06 06d (R( (8##,$M>7KK'(9;MwWO$% 05wG ,6"G$$*I$ $18 RRR/ R R2G .-]NGTK.`0@D"8< 8,176D$("&/3$(#' $hh!h h - h " h!hh&h h",',--    &  +   #  -159  ) 3   +     )-15.2 Q%Q/Q, Q ' Q J Q(**k7KH  $      "    '       )-15#  % /     '     )-15.2#  % / ,    '   > :-]OWUK   "  '   #  )-15  % /   '     )-15.2 V%V/V, V ' V J V(1.O   $      "    '       )-15#  % /     '     )-15.2#  % / ,    '   > :20'317    &  +   #  -159  ) 3   +     )-15.2 U%U/U, U ' U J U(.nowWL  $      "    '       )-15#  % /     '     )-15.2#  % / ,    '   > :1.O2/    "  '   #  )-15  % /   '     )-15.2  % / ,  '  J  ,56   $      "    '       )-15#  % /     '     )-15.2#  % / ,    '   > :6 8'7!97 )-15%/'   8,L-QJ)-15#  % /   '    0-]NGTK-nngVL !!%%   &/,' $0?2%?2/?2, ?2  ?2 ) ?2'?2 ?2F2222  66   66   ,,<<'*"+"'*"+"$g.&/&$g.&/&G$%rVrceZdZUdZdZded<dZded<ddZdddZdd Z dfd Z e dd Z ddd Z e dd ZejddZdej"f ddZe ddZxZS)r<zA Python string that is part of a parse tree. When Beautiful Soup parses the markup ``penguin``, it will create a `NavigableString` for the string "penguin". rrCPREFIXSUFFIXct|trtj||}ntj||t}d|_|j |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. F)rrCrkrXrr)rlrus rTrkzNavigableString.__new__ sF eS ! C'A C(?@A  rVFc$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__. )typers rTrzNavigableString.__deepcopy__stDz$rVct|fSr)rCrs rT__getnewargs__zNavigableString.__getnewargs__'sD |rVct|tr.tdj|jj t t|#|S)zRaise an exception zZstring indices must be integers, not '{0}'. Are you treating a NavigableString like a Tag?) rrC TypeErrorrNrrRrr< __getitem__)r|rrs rTrzNavigableString.__getitem__,s` c3 xADANANAWAWXY Y_d7<`_.z rNrRrprqrrrrsrrtrVrTrrs[FCFCrVrc.eZdZUdZdZded<dZded<y)ProcessingInstructionzA SGML processing instruction.rNrrtrVrTrrs(FCFCrVrc.eZdZUdZdZded<dZded<y)XMLProcessingInstructionzIAn `XML processing instruction `_.rrCr?>rNrrtrVrTrrsSFCFCrVrc.eZdZUdZdZded<dZded<y)CommentzAn `HTML comment `_ or `XML comment `_.zrNrrtrVrTr r sVFCFCrVr c.eZdZUdZdZded<dZded<y) DeclarationzFAn `XML declaration `_.rrCrrrNrrtrVrTr r sPFCFCrVr creZdZUdZe d dZe d dZdZded<dZ ded<y ) DoctypezKA `document type declaration `_.rCc:t|j|||S)aGenerate 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' )r_string_for_name_and_ids)rlrFpub_id system_ids rTfor_name_and_idszDoctype.for_name_and_idsss33D&)LMMrVcR|xsd}||d|zz }||d|zz }|S||d|zz }|S)zGenerate a string to be used as the basis of a Doctype object. This is a separate method from for_name_and_ids() because the lxml TreeBuilder needs to call it. rz PUBLIC "%s"z "%s"z SYSTEM "%s"rt)rlrFrrrs rTrz Doctype._string_for_name_and_idssZ    ^f, ,E$9,,  " ^i/ /E rVz rN)rFrCrrfrrfror)rFrCrrfrrfrorC) rRrprqrr classmethodrrrrsrrtrVrTrrsU N N - N:G N  N N -:G "FCFCrVrceZdZdZy) StylesheetzA `NavigableString` representing the contents of a `