libearth.parser.autodiscovery — Autodiscovery¶
This module provides functions to autodiscovery feed url in document.
-
libearth.parser.autodiscovery.ATOM_TYPE= 'application/atom+xml'¶ (
str) The MIME type of Atom format (application/atom+xml).
-
libearth.parser.autodiscovery.RSS_TYPE= 'application/rss+xml'¶ (
str) The MIME type of RSS 2.0 format (application/rss+xml).
-
libearth.parser.autodiscovery.TYPE_TABLE= {<function parse_rss at 0x7fe1db2b5140>: 'application/rss+xml', <function parse_atom at 0x7fe1db2b1668>: 'application/atom+xml'}¶ (
collections.Mapping) The mapping table of feed types
-
class
libearth.parser.autodiscovery.AutoDiscovery¶ Parse the given HTML and try finding the actual feed urls from it.
Changed in version 0.3.0: It became to find icon links as well, and
find_feed_url()method (that returned only feed links) was gone, insteadfind()(that return a pair of feed links and icon links) was introduced.
-
class
libearth.parser.autodiscovery.FeedLink(type, url)¶ Namedtuple which is a pair of
type` and ``url-
type¶ Alias for field number 0
-
url¶ Alias for field number 1
-
-
exception
libearth.parser.autodiscovery.FeedUrlNotFoundError(msg)¶ Exception raised when feed url cannot be found in html.
-
libearth.parser.autodiscovery.autodiscovery(document, url)¶ If the given url refers an actual feed, it returns the given url without any change.
If the given url is a url of an ordinary web page (i.e. text/html), it finds the urls of the corresponding feed. It returns feed urls in feed types’ lexicographical order.
If autodiscovery failed, it raise
FeedUrlNotFoundError.Parameters: Returns: list of
FeedLinkobjectsReturn type: collections.MutableSequence
-
libearth.parser.autodiscovery.get_format(document)¶ Guess the syndication format of an arbitrary
document.Parameters: document ( str,bytes) – document string to guessReturns: the function possible to parse the given documentReturn type: collections.CallableChanged in version 0.2.0: The function was in
libearth.parser.heuristicmodule (which is removed now) before 0.2.0, but now it’s moved tolibearth.parser.autodiscovery.