| Trees | Index | Help |
|---|
| Package CPSRSS :: Module feedparser |
|
Universal feed parser
Handles RSS 0.9x, RSS 1.0, RSS 2.0, CDF, Atom feeds
Visit http://feedparser.org/ for the latest version Visit http://feedparser.org/docs/ for the latest documentation
Required: Python 2.1 or later Recommended: Python 2.3 or later Recommended: libxml2 <http://xmlsoft.org/python.html>| Classes | |
|---|---|
FeedParserDict |
|
_BaseHTMLProcessor |
|
_FeedParserMixin |
|
_FeedURLHandler |
|
_HTMLSanitizer |
|
_LooseFeedParser |
|
_RelativeURIResolver |
|
_StrictFeedParser |
|
| Exceptions | |
|---|---|
CharacterEncodingOverride |
|
CharacterEncodingUnknown |
|
| Function Summary | |
|---|---|
Parse a feed from a URL, file, stream, or string | |
_ebcdic_to_ascii(str)
| |
Get the character encoding of the XML document | |
URL, filename, or string --> stream | |
Parses a variety of date formats into a tuple of 9 integers | |
_resolveRelativeURIs(htmlSource,
baseURI,
encoding)
| |
_sanitizeHTML(htmlSource,
encoding)
| |
Strips DOCTYPE from XML document, returns (rss_version, stripped_data) | |
Changes an XML data stream on the fly to specify a new encoding | |
_w3dtf_parse(s)
| |
| Variable Summary | |
|---|---|
str |
__author__ = 'Mark Pilgrim <http://diveintomark.org/>'
|
list |
__contributors__ = ['Jason Diamond <http://injektilo.org...
|
str |
__copyright__ = 'Copyright 2002-4, Mark Pilgrim'
|
str |
__license__ = 'Python'
|
str |
__version__ = '3.2'
|
str |
ACCEPT_HEADER = 'application/atom+xml,application/rdf+xm...
|
list |
PREFERRED_XML_PARSERS = ['drv_libxml2']
|
tuple |
python_version = (2, 4)
|
dict |
SUPPORTED_VERSIONS = {'': 'unknown', 'cdf': 'CDF', 'rss0...
|
int |
TIDY_MARKUP = 0 |
str |
USER_AGENT = 'UniversalFeedParser/3.2 +http://feedparser...
|
dict |
_additional_timezones = {'ET': -500, 'MT': -700, 'AT': -...
|
int |
_debug = 0 |
list |
_iso8601_matches = [<built-in method match of _sre.SRE_P...
|
list |
_iso8601_re = ['(?P<year>\\d{4})-?(?P<month>[01]\\d)-?(?...
|
list |
_iso8601_tmpl = ['YYYY-?MM-?DD', 'YYYY-MM', 'YYYY-?OOO',...
|
SRE_Pattern |
_korean_date_1_re = (\d{4})년\s+(\d{2})월\s+(\d{2})일...
|
unicode |
_korean_day = u'\xec\x9d\xbc'
|
unicode |
_korean_month = u'\xec\x9b\x94'
|
unicode |
_korean_year = u'\xeb\x85\x84'
|
NoneType |
_mxtidy = None |
| Function Details |
|---|
parse(url_file_stream_or_string, etag=None, modified=None, agent=None, referrer=None, handlers=[])Parse a feed from a URL, file, stream, or string |
_getCharacterEncoding(http_headers, xml_data)Get the character encoding of the XML document http_headers is a dictionary xml_data is a raw string (not Unicode) This is so much trickier than it sounds, it's not even funny. According to RFC 3023 ("XML Media Types"), if the HTTP Content-Type is application/xml, application/*+xml, application/xml-external-parsed-entity, or application/xml-dtd, the encoding given in the charset parameter of the HTTP Content-Type takes precedence over the encoding given in the XML prefix within the document, and defaults to "utf-8" if neither are specified. But, if the HTTP Content-Type is text/xml, text/*+xml, or text/xml-external-parsed-entity, the encoding given in the XML prefix within the document is ALWAYS IGNORED and only the encoding given in the charset parameter of the HTTP Content-Type header should be respected, and it defaults to "us-ascii" if not specified. Furthermore, discussion on the atom-syntax mailing list with the author of RFC 3023 leads me to the conclusion that any document served with a Content-Type of text/* and no charset parameter must be treated as us-ascii. (We now do this.) And also that it must always be flagged as non-well-formed. (We do not do this.) If Content-Type is unspecified (input was local file or non-HTTP source) or unrecognized (server just got it totally wrong), then go by the encoding given in the XML prefix of the document and default to "utf-8" as per the XML specification. This part is probably wrong, as HTTP defaults to "iso-8859-1" if no Content-Type is specified. Also, the default Content-Type and well-formedness of XML documents served as wacky types like "application/octet-stream" is still under discussion. |
_open_resource(url_file_stream_or_string, etag, modified, agent, referrer, handlers)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 must be a tuple of 9 integers as returned by gmtime() in the standard Python time module. This MUST be in GMT (Greenwich Mean Time). The formatted date/time will be 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. |
_parse_date(date)Parses a variety of date formats into a tuple of 9 integers |
_stripDoctype(data)Strips DOCTYPE from XML document, returns (rss_version, stripped_data) rss_version may be "rss091n" or None stripped_data is the same XML document, minus the DOCTYPE |
_toUTF8(data, encoding)Changes an XML data stream on the fly to specify a new encoding data is a raw sequence of bytes (not Unicode) that is presumed to be in %encoding already encoding is a string recognized by encodings.aliases |
| Variable Details |
|---|
__author__
|
__copyright__
|
__license__
|
__version__
|
ACCEPT_HEADER
|
PREFERRED_XML_PARSERS
|
python_version
|
SUPPORTED_VERSIONS
|
TIDY_MARKUP
|
USER_AGENT
|
_additional_timezones
|
_debug
|
_iso8601_matches
|
_iso8601_re
|
_iso8601_tmpl
|
_korean_date_1_re
|
_korean_day
|
_korean_month
|
_korean_year
|
_mxtidy
|
| Trees | Index | Help |
|---|
| Generated by Epydoc 2.1 on Mon Jun 27 12:47:50 2005 | http://epydoc.sf.net |