
    !hT                        S r SSKJr  SSKJr  SSKJr  SSKJ	r	J
r
Jr  SSKJr  SSKJr  SSKJr  S	S
/r\" 5       rSS jrSS jr " S S
\R.                  \5      r " S S	\\5      rg)z
XPath selectors based on lxml
    )annotations)Any)Selector)HtmlResponseTextResponseXmlResponse)to_bytes)get_base_url)
object_refr   SelectorListc                >    Uc  [        U [        5      (       a  S$ S$ U$ )Nxmlhtml)
isinstancer   )responsests     ^/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/scrapy/selector/unified.py_str      s#    	z"8[99uEvEI    c                J    US:X  a  [         O[        nU" SS[        U S5      S9$ )Nr   zabout:blankzutf-8)urlencodingbody)r   r   r	   )textr   rts      r   _response_from_textr      s%    ,.%K[\B-'w8OPPr   c                      \ rS rSrSrSrg)r       zw
The :class:`SelectorList` class is a subclass of the builtin ``list``
class, which provides a few additional methods.
 N)__name__
__module____qualname____firstlineno____doc____static_attributes__r   r   r   r   r       s    r   c                  X   ^  \ rS rSrSrS/r\rSSS\4         SU 4S jjjr	Sr
U =r$ )r   '   ab  
An instance of :class:`Selector` is a wrapper over response to select
certain parts of its content.

``response`` is an :class:`~scrapy.http.HtmlResponse` or an
:class:`~scrapy.http.XmlResponse` object that will be used for selecting
and extracting data.

``text`` is a unicode string or utf-8 encoded text for cases when a
``response`` isn't available. Using ``text`` and ``response`` together is
undefined behavior.

``type`` defines the selector type, it can be ``"html"``, ``"xml"``, ``"json"``
or ``None`` (default).

If ``type`` is ``None``, the selector automatically chooses the best type
based on ``response`` type (see below), or defaults to ``"html"`` in case it
is used together with ``text``.

If ``type`` is ``None`` and a ``response`` is passed, the selector type is
inferred from the response type as follows:

* ``"html"`` for :class:`~scrapy.http.HtmlResponse` type
* ``"xml"`` for :class:`~scrapy.http.XmlResponse` type
* ``"json"`` for :class:`~scrapy.http.TextResponse` type
* ``"html"`` for anything else

Otherwise, if ``type`` is set, the selector type will be forced and no
detection will occur.
r   Nc                &  > Ub%  Ub"  [        U R                  R                   S35      e[        X5      nUb  [	        X&5      nUb'  UR
                  nUR                  S[        U5      5        Xl        U[        La  XES'   [        TU ],  " SX&S.UD6  g )Nz+.__init__() received both response and textbase_urlroot)r   typer   )
ValueError	__class__r    r   r   r   
setdefaultr
   r   _NOT_SETsuper__init__)selfr   r   r+   r*   kwargsr   r-   s          r   r1   Selector.__init__J   s     D$4>>**++VW   *44H==Dj,x*@A x!6N6d6v6r   )r   )
r   TextResponse | Noner   
str | Noner+   r6   r*   z
Any | Noner3   r   )r    r!   r"   r#   r$   	__slots__r   selectorlist_clsr/   r1   r%   __classcell__)r-   s   @r   r   r   '   s_    > I# )-#7%7 7 	7
 7 7 7r   N)r   r5   r   r6   returnstr)r   zstr | bytesr   r6   r:   r   )r$   
__future__r   typingr   parselr   _ParselSelectorscrapy.httpr   r   r   scrapy.utils.pythonr	   scrapy.utils.responser
   scrapy.utils.trackrefr   __all__objectr/   r   r   r8   r   r   r   r   <module>rF      sb    #  . ? ? ( . ,~
&8Q
?33Z >7
 >7r   