
    !}gs,                        d dl Z d dlZd dlZd dlZddlmZmZ ddl	m
Z
 ddlT ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlT ddlmZmZ ddlmZ dgZdZi dddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0Z d1 Z! e"d2eeee#fi           Z$ e"d3eeej%        j&        j'        e#fi           Z(d5d4Z)dS )6    N   )registerDateHandler_parse_date)convert_to_utf8)*)_BaseHTMLProcessor)http)mixin)_FeedParserMixin)_LooseFeedParser)_StrictFeedParser)replace_doctype)convert_to_idnmake_safe_absolute_uri)FeedParserDictdrv_libxml2T unknownrss090zRSS 0.90rss091nzRSS 0.91 (Netscape)rss091uzRSS 0.91 (Userland)rss092zRSS 0.92rss093zRSS 0.93rss094zRSS 0.94rss20zRSS 2.0rss10zRSS 1.0rsszRSS (unknown version)atom01zAtom 0.1atom02zAtom 0.2atom03zAtom 0.3atom10zAtom 1.0atomzAtom (unknown version)cdfCDFc           
         t          | d          r|                                 S t          | t                    rBt          j                            |           d         dv rt          j        | |||||||          S 	 t          | d          5 }|                                }	ddd           n# 1 swxY w Y   |	S # t          t          t          t          f$ r Y nw xY wt          | t                    s|                     d          S | S )aE  URL, filename, or string --> stream

    This function lets you define parsers that take any input source
    (URL, pathname to local or network file, or actual data as a string)
    and deal with it in a uniform manner.  Returned object is guaranteed
    to have all the basic stdio read methods (read, readline, readlines).
    Just .close() the object when you're done with it.

    If the etag argument is supplied, it will be used as the value of an
    If-None-Match request header.

    If the modified argument is supplied, it can be a tuple of 9 integers
    (as returned by gmtime() in the standard Python time module) or a date
    string in any format supported by feedparser. Regardless, it MUST
    be in GMT (Greenwich Mean Time). It will be reformatted into an
    RFC 1123-compliant date and used as the value of an If-Modified-Since
    request header.

    If the agent argument is supplied, it will be used as the value of a
    User-Agent request header.

    If the referrer argument is supplied, it will be used as the value of a
    Referer[sic] request header.

    If handlers is supplied, it is a list of handlers used to build a
    urllib2 opener.

    if request_headers is supplied it is a dictionary of HTTP request headers
    that will override the values generated by FeedParser.

    :return: A bytes object.
    readr   )r	   httpsftpfilefeedrbNutf-8)hasattrr&   
isinstancestrurllibparseurlparser	   getopenIOErrorUnicodeEncodeError	TypeError
ValueErrorbytesencode)
url_file_stream_or_stringetagmodifiedagentreferrerhandlersrequest_headersresultfdatas
             N/var/www/py-google-trends/myenv/lib/python3.11/site-packages/feedparser/api.py_open_resourcerF   L   s[   D (&11 0(--///+S11 w<  !:;;A>Bjjjx145(T\^mouvvv+T22 	a6688D	 	 	 	 	 	 	 	 	 	 	 	 	 	 	  'J?    	 /77 9(//888$$s6   =B; B."B; .B22B; 5B26B; ;CCLooseFeedParserStrictFeedParserc
           
         |r|	|ddl }
|s|
j        }|	|
j        }	||
j        }t	          dg t	                      i           }	 t          | |||||||          }n;# t          j        j        $ r$}|	                    d|d           |cY d}~S d}~ww xY w|s|S |d         	                    |pi            t          |d         ||          }|d         rdpd}t          |          \  |d	<   }}|d                             d
d          }|                    dd          }t          ||          pt          |          p|}|d                             dd          }t          |t                    r||                    dd          }t"          sd}|rrt%          ||d          }
||
_        |	|
_        t*          j                            t0                    }|                    t*          j        j        j        d           	 |                    t*          j        j        j        d           n# t*          j        j        $ r Y nw xY w|                    |
           |                    |
           t*          j        j         !                                }|"                    tG          j$        |                     	 |%                    |           n4# t*          j        j&        $ r}d|d<   |
j'        p||d<   d}Y d}~nd}~ww xY w|sItQ          ||d|          }
||
_        |	|
_        |
)                    |                    dd                     |
j*        |d<   |
j+        |d<   |d	         p|
j,        |d	<   |
j-        |d<   |S )a  Parse a feed from a URL, file, stream, or string.

    :param url_file_stream_or_string:
        File-like object, URL, file path, or string. Both byte and text strings
        are accepted. If necessary, encoding will be derived from the response
        headers or automatically detected.

        Note that strings may trigger network I/O or filesystem access
        depending on the value. Wrap an untrusted string in
        a :class:`io.StringIO` or :class:`io.BytesIO` to avoid this. Do not
        pass untrusted strings to this function.

        When a URL is not passed the feed location to use in relative URL
        resolution should be passed in the ``Content-Location`` response header
        (see ``response_headers`` below).

    :param str etag: HTTP ``ETag`` request header.
    :param modified: HTTP ``Last-Modified`` request header.
    :type modified: :class:`str`, :class:`time.struct_time` 9-tuple, or
        :class:`datetime.datetime`
    :param str agent: HTTP ``User-Agent`` request header, which defaults to
        the value of :data:`feedparser.USER_AGENT`.
    :param referrer: HTTP ``Referer`` [sic] request header.
    :param request_headers:
        A mapping of HTTP header name to HTTP header value to add to the
        request, overriding internally generated values.
    :type request_headers: :class:`dict` mapping :class:`str` to :class:`str`
    :param response_headers:
        A mapping of HTTP header name to HTTP header value. Multiple values may
        be joined with a comma. If a HTTP request was made, these headers
        override any matching headers in the response. Otherwise this specifies
        the entirety of the response headers.
    :type response_headers: :class:`dict` mapping :class:`str` to :class:`str`

    :param bool resolve_relative_uris:
        Should feedparser attempt to resolve relative URIs absolute ones within
        HTML content?  Defaults to the value of
        :data:`feedparser.RESOLVE_RELATIVE_URIS`, which is ``True``.
    :param bool sanitize_html:
        Should feedparser skip HTML sanitization? Only disable this if you know
        what you are doing!  Defaults to the value of
        :data:`feedparser.SANITIZE_HTML`, which is ``True``.

    :return: A :class:`FeedParserDict`.
    Nr   F)bozoentriesr*   headersT)rJ   bozo_exceptionrL   encodingversionzcontent-locationr   hrefzcontent-languager,   ignorer   rJ   rM   replacer*   rK   
namespaces).
feedparser
USER_AGENTSANITIZE_HTMLRESOLVE_RELATIVE_URISr   rF   r0   errorURLErrorupdater   r   r3   r   r.   r9   decode_XML_AVAILABLErH   resolve_relative_urissanitize_htmlxmlsaxmake_parserPREFERRED_XML_PARSERS
setFeaturehandlerfeature_namespacesfeature_external_gesSAXNotSupportedExceptionsetContentHandlersetErrorHandler	xmlreaderInputSourcesetByteStreamioBytesIOr1   SAXExceptionexcrG   r*   feeddatarK   rO   namespaces_in_use)r;   r<   r=   r>   r?   r@   rA   response_headersr]   r^   rT   rB   rD   rX   use_strict_parserentities
contentlocrP   baseuribaselang	saxparsersourcees                          rE   r1   r1      s   ^  M)-B-J &%"0$ * @	  F7xPXZbdsu{||<    #
 
 	 	 	    9-34446),dF;;Dz*3t<u(7(=(=%F9tX 	"&&'92>>J::fb!!D$T:66d:PQ[:\:\d`dGi $$%7>>H(E"" 6x';??7H55  "%gxAA
+@
(#0
 G''(=>>	SW_?CCC	  !EqIIIIw/ 	 	 	D	##J///!!*---"..00RZ--...	"OOF####w# 	" 	" 	"F6N'1~':F#$ !	"  9$WhJJ
+@
(#0
 GY77888(F6N"*F9y)?Z-?F9%7F<MsH   A B1B
BB*H3 3I
	I
K L	,LL	)	NNNNNNNNN)*rm   urllib.errorr0   urllib.parsexml.saxr_   	datetimesr   r   	encodingsr   
exceptionshtmlr   r   r	   r
   r   parsers.looser   parsers.strictr   	sanitizerr   sgmlurlsr   r   utilr   rb   r\   SUPPORTED_VERSIONSrF   typeobjectrG   r`   rd   ContentHandlerrH   r1        rE   <module>r      s{  : 
			          7 7 7 7 7 7 7 7 & & & & & &     $ $ $ $ $ $             # # # # # # + + + + + + - - - - - - & & & & & &     8 8 8 8 8 8 8 8             ' 	j $ $	
 j j j Y Y 
" j j j j $  
5! (<% <% <%~ $');VD  4(#'/*H&Q  } } } } } }r   