Format: application/x-python-code
1 o
2
3 /'hs, � @ sn d dl Z d dlZd dlZd dlZddlmZmZ ddl m
4 Z
5 ddlT ddlm
6 Z
7 ddlmZ ddlmZ dd lmZ dd
8 lmZ ddlmZ ddlmZ ddlT dd
9 lmZmZ ddlmZ dgZdZi dd�dd�dd�dd�dd�dd�dd�dd �d!d"�d#d$�d%d&�d'd(�d)d*�d+d,�d-d.�d/d0�Z d1d2� Z!e"d3eee
10 e#fi �Z$e"d4eeej%j&j'e#fi �Z(d7d5d6�Z)dS )8� N� )�registerDateHandler�_parse_date)�convert_to_utf8)�*)�_BaseHTMLProcessor)�http)�mixin)�_FeedParserMixin)�_LooseFeedParser)�_StrictFeedParser)�replace_doctype)�convert_to_idn�make_safe_absolute_uri)�FeedParserDictZdrv_libxml2T� �unknownZrss090zRSS 0.90Zrss091nzRSS 0.91 (Netscape)Zrss091uzRSS 0.91 (Userland)Zrss092zRSS 0.92Zrss093zRSS 0.93Zrss094zRSS 0.94Zrss20zRSS 2.0Zrss10zRSS 1.0ZrsszRSS (unknown version)Zatom01zAtom 0.1Zatom02zAtom 0.2Zatom03zAtom 0.3Zatom10zAtom 1.0ZatomzAtom (unknown version)ZcdfZCDFc
11 C s� t | d�r | �� S t| t�r$tj�| �d dv r$t�| |||||||�S zt | d��}|�� } W d � W | S 1 s;w Y W | S t
12 ttt
13 fyO Y nw t| t�sZ| �d�S | S )aE URL, filename, or string --> stream
14
15 This function lets you define parsers that take any input source
16 (URL, pathname to local or network file, or actual data as a string)
17 and deal with it in a uniform manner. Returned object is guaranteed
18 to have all the basic stdio read methods (read, readline, readlines).
19 Just .close() the object when you're done with it.
20
21 If the etag argument is supplied, it will be used as the value of an
22 If-None-Match request header.
23
24 If the modified argument is supplied, it can be a tuple of 9 integers
25 (as returned by gmtime() in the standard Python time module) or a date
26 string in any format supported by feedparser. Regardless, it MUST
27 be in GMT (Greenwich Mean Time). It will be reformatted into an
28 RFC 1123-compliant date and used as the value of an If-Modified-Since
29 request header.
30
31 If the agent argument is supplied, it will be used as the value of a
32 User-Agent request header.
33
34 If the referrer argument is supplied, it will be used as the value of a
35 Referer[sic] request header.
36
37 If handlers is supplied, it is a list of handlers used to build a
38 urllib2 opener.
39
40 if request_headers is supplied it is a dictionary of HTTP request headers
41 that will override the values generated by FeedParser.
42
43 :return: A bytes object.
44 �readr )r �https�ftp�file�feed�rbN�utf-8)�hasattrr �
45 isinstance�str�urllib�parse�urlparser �get�open�IOError�UnicodeEncodeError� TypeError�
46 ValueError�bytes�encode)
47 �url_file_stream_or_string�etag�modified�agent�referrer�handlers�request_headers�result�f�data� r2 �DC:\Users\shubh\Videos\agent\nova\Lib\site-packages\feedparser/api.py�_open_resourceL s$
48 "
49
50 ����
51
52 r4 �LooseFeedParser�StrictFeedParserc
53
54 C s� |r
55 | du s
56 |du rddl }
57 |s|
58 j}| du r|
59 j} |du r!|
60 j}tdg t� i d�}z
61 t| |||||||�}W n tjjyU }
62 z|� d|
63 d�� |W Y d}
64 ~
65 S d}
66 ~
67 ww |sZ|S |d � |pai � t
68 |d ||�}|d rqdprd}t|�\|d <