
    3 df
                         d Z ddlmZ ddlmZmZ ddlmZ ddl	m
Z
 ddgZd Zd	 Z G d
 dej        e
          Z G d dee
          ZdS )z
XPath selectors based on lxml
    )Selector)HtmlResponseXmlResponse)to_bytes)
object_refr   SelectorListc                 <    |t          | t                    rdndS |S )Nxmlhtml)
isinstancer   )responsests     7lib/python3.11/site-packages/scrapy/selector/unified.py_str      s)    	 F"8[99EuuvEI    c                 b    |dk    rt           nt          } |ddt          | d                    S )Nr
   zabout:blankzutf-8)urlencodingbody)r   r   r   )textr   rts      r   _response_from_textr      s5    e	5B2-'w8O8OPPPPr   c                       e Zd ZdZdS )r   z
    The :class:`SelectorList` class is a subclass of the builtin ``list``
    class, which provides a few additional methods.
    N)__name__
__module____qualname____doc__ r   r   r   r      s           r   c                   .     e Zd ZdZdgZeZd fd	Z xZS )r   aq  
    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"``
    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
    * ``"html"`` for anything else

    Otherwise, if ``type`` is set, the selector type will be forced and no
    detection will occur.
    r   Nc                    ||t          | j        j         d          t          ||          }|t	          ||          }|"|j        }|                    d|j                   || _         t                      j
        d|||d| d S )Nz+.__init__() received both response and textbase_url)r   typerootr   )
ValueError	__class__r   r   r   r   
setdefaultr   r   super__init__)selfr   r   r"   r#   kwargsr   r%   s          r   r(   zSelector.__init__B   s     	D 	>* ) ) )  
 4   	5*444H 	8=Dj(,777 Ad$AA&AAAAAr   )NNNN)	r   r   r   r   	__slots__r   selectorlist_clsr(   __classcell__)r%   s   @r   r   r       s`         < I#B B B B B B B B B Br   N)r   parselr   _ParselSelectorscrapy.httpr   r   scrapy.utils.pythonr   scrapy.utils.trackrefr   __all__r   r   r,   r   r   r   r   <module>r4      s     / . . . . . 1 1 1 1 1 1 1 1 ( ( ( ( ( ( , , , , , ,~
&  Q Q Q
    ?3Z   3B 3B 3B 3B 3B
 3B 3B 3B 3B 3Br   