Format: application/x-python-code
⬇ Download File (5.0 KB)
   1  o
   2  
   3  /'ht&�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
   4  mZddlm
   5  Z
   6  dZGdd�dejjejjejj�Zdd	�Zdd
   7  d�ZdS)
   8  �N�)�_parse_date)�convert_to_idnz�application/atom+xml,application/rdf+xml,application/rss+xml,application/x-netcdf,application/xml;q=0.9,text/xml;q=0.2,*/*;q=0.1c@s4eZdZdd�Zdd�ZeZeZeZeZdd�Z	dS)�_FeedURLHandlercCs
   9  ||_|S�N)�status)�self�req�fp�code�msg�headers�r�EC:\Users\shubh\Videos\agent\nova\Lib\site-packages\feedparser/http.py�http_error_default0sz"_FeedURLHandler.http_error_defaultcCs4tjj�||||||�}|s|S||_|��|_|Sr)�urllib�request�HTTPRedirectHandler�http_error_301r�geturl�newurl)rr	r
  10  rr�hdrs�resultrrrr6s
  11  z_FeedURLHandler.http_error_301cCs�tj�|���d}d|jvsd|vr|�|||||�St�|jd�d�d�	���
  12  �}|�d�\}}	t�d|d�d}
  13  |�
  14  |
  15  |||	�|�d|||�}|��|S)	Nr�
  16  AuthorizationzWWW-Authenticate� �:zrealm="([^"]*)"rzwww-authenticate)r�parse�urlparse�get_full_urlr
  17  r�base64�decodebytes�split�encode�decode�re�findall�add_password�http_error_auth_reqed�reset_retry_count)rr	r
  18  rrr
  19  �host�auth�userZpassw�realm�retryrrr�http_error_401Fs
  20  "z_FeedURLHandler.http_error_401N)
  21  �__name__�
  22  __module__�__qualname__rrZhttp_error_300�http_error_302�http_error_303�http_error_307r.rrrrr/src
  23  Cstj�|�}|�d|�|r|�d|�t|t�rt|�}n
  24  t|tj�r(|��}|rUgd�}	gd�}
  25  |�dd|	|d|d|
  26  |d	d	|d
  27  |d|d|d
  28  f�|r]|�d|�|�dd�|rm|�dd|�|ru|�d|�|�	�D]
  29  \}}|�||�qy|�dd�|S)Nz
  30  User-Agentz
  31  If-None-Match)�Mon�Tue�Wed�Thu�Fri�Sat�Sun)�Jan�Feb�Mar�Apr�May�Jun�Jul�Aug�Sep�Oct�Nov�DeczIf-Modified-Sincez#%s, %02d %s %04d %02d:%02d:%02d GMT��rr���ZRefererzAccept-encodingz
  32  gzip, deflaterzBasic %s�AcceptzA-IM�feed)
  33  rr�Request�
  34  add_header�
  35  isinstance�strr�datetime�utctimetuple�items)
  36  �url�agentZ
  37  accept_header�etag�modified�referrerr*�request_headersrZshort_weekdays�months�header_name�header_valuerrr�_build_urllib2_request\s.
  38  
  39  Fr_c
  40  Cs�|durg}nt|t�s|g}|duri}|�d�r!|dd�}n
  41  |�d�r.d|dd�}|s8ddlm}|}d}	|�d�sutj�|�}
  42  |
  43  jrut|
  44  �}|
  45  j	|d<|
  46  j
  47  r_|
  48  j	�d|
  49  j
  50  ��|d<tj�|�}t�
  51  |
  52  j�d|
  53  j�������}	t|t�s~t|�}g}|D]!}
  54  z|
  55  �d	�Wnty�|�tj�|
  56  ��Yq�w|�|
  57  �q�d
  58  �|�}t||t||||	|�}tjjt|t�g��}g|_|�|�}|��}|� �dd�|j!�"�D�|d
  59  <|�r d|d
  60  �#dd
  61  �v�r z
  62  t$j%t&�'|�d���}Wnnt(t)t*j+f�y}zd|d<||d<t|t*j+��rd}WYd}~nKd}~ww|�rfd|d
  63  �#dd
  64  �v�rfzt,�-|�}Wn0t,j+�yezt,�-|d�}Wnt,j+�yb}zd|d<||d<WYd}~nd}~wwYnwd|d
  65  v�r�|d
  66  �#dd
  67  �}t|t��r�|�dd�}|�r�||d<d|d
  68  v�r�|d
  69  �#dd
  70  �}|�r�||d<t.|�|d<t|j/t��r�|j/�dd�|d<n|j/|d<t0|dd��p�d|d<t0|dd �d!k�r�d
  71  |d"<d#|d$<|S)%Nz	feed:httprLzfeed:zhttp:r)�
  72  USER_AGENTzftp:r�ascii�cSsi|]	\}}|��|�qSr)�lower)�.0�k�vrrr�
  73  <dictcomp>�szget.<locals>.<dictcomp>r
  74  �gzipzcontent-encoding)�fileobjTZbozoZbozo_exception�deflatei����rXzutf-8�ignorez
  75  last-modifiedrYZmodified_parsed�hrefr��rri0�versionzkThe feed has not changed since you last checked, so the server sent no data.  This is a feature, not a bug!Z
  76  debug_message)1rQ�list�
  77  startswithrbr`rrr�username�hostname�port�
  78  urlunparser�standard_b64encode�passwordr"r#�bytesr�UnicodeEncodeError�append�quote�joinr_�
  79  ACCEPT_HEADERr�build_opener�tupler�
  80  addheaders�open�read�closer
  81  rU�getrh�GzipFile�io�BytesIO�EOFError�IOError�struct�error�zlib�
  82  decompressrrV�getattr)rVrXrYrWrZ�handlersr[rr`r*�
  83  url_piecesZ
  84  new_pieces�bits�cr�opener�f�data�errrr�|s�
  85  
  86  
  87  
  88  
  89   
  90  �
  91  
  92  ��
  93  ����	
  94  r�)NNNNNNN)rrSrhr�r$r��urllib.parser�urllib.requestr�Z	datetimesr�urlsrr|r�HTTPDigestAuthHandlerr�HTTPDefaultErrorHandlerrr_r�rrrr�<module>s -