How to use the feedparser.RESOLVE_RELATIVE_URIS function in feedparser

To help you get started, we’ve selected a few feedparser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ghoseb / planet.clojure / planet / __init__.py View on Github external
logger = logging.getLogger("planet.runner")
    logger.setLevel(logging.getLevelName(level))
    try:
        logger.warning
    except:
        logger.warning = logger.warn

    loggerParms = (level,format)
    return logger

sys.path.insert(1, os.path.join(os.path.dirname(__file__),'vendor'))

# Configure feed parser
import feedparser
feedparser.SANITIZE_HTML=1
feedparser.RESOLVE_RELATIVE_URIS=0

import publish
github lemon24 / reader / src / reader / _parser.py View on Github external
else:

        # This is in no way thread-safe, but what can you do?
        # TODO: Well, you could use locks to make it threadsafe...
        # https://docs.python.org/3/library/threading.html#lock-objects

        old_RESOLVE_RELATIVE_URIS = feedparser.RESOLVE_RELATIVE_URIS
        old_SANITIZE_HTML = feedparser.SANITIZE_HTML
        feedparser.RESOLVE_RELATIVE_URIS = True
        feedparser.SANITIZE_HTML = True

        try:
            yield feedparser.parse
        finally:
            feedparser.RESOLVE_RELATIVE_URIS = old_RESOLVE_RELATIVE_URIS
            feedparser.SANITIZE_HTML = old_SANITIZE_HTML
github lemon24 / reader / src / reader / _parser.py View on Github external
def parse(*args: Any, **kwargs: Any) -> Any:
            return feedparser.parse(
                *args, resolve_relative_uris=True, sanitize_html=True, **kwargs
            )

        yield parse

    else:

        # This is in no way thread-safe, but what can you do?
        # TODO: Well, you could use locks to make it threadsafe...
        # https://docs.python.org/3/library/threading.html#lock-objects

        old_RESOLVE_RELATIVE_URIS = feedparser.RESOLVE_RELATIVE_URIS
        old_SANITIZE_HTML = feedparser.SANITIZE_HTML
        feedparser.RESOLVE_RELATIVE_URIS = True
        feedparser.SANITIZE_HTML = True

        try:
            yield feedparser.parse
        finally:
            feedparser.RESOLVE_RELATIVE_URIS = old_RESOLVE_RELATIVE_URIS
            feedparser.SANITIZE_HTML = old_SANITIZE_HTML
github lemon24 / reader / reader / _feedparser_parse_data.py View on Github external
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`.
    '''

    if sanitize_html is None or resolve_relative_uris is None:
        import feedparser
    if sanitize_html is None:
        sanitize_html = feedparser.SANITIZE_HTML
    if resolve_relative_uris is None:
        resolve_relative_uris = feedparser.RESOLVE_RELATIVE_URIS

    result = _make_empty_result()

    if href:
        result['href'] = href
    if response_headers:
        result['headers'] = response_headers or {}

    return _parse_data(data, result, resolve_relative_uris, sanitize_html)
github ranveeraggarwal / iitb-blog-aggregator / rawdog / rawdoglib / rawdog.py View on Github external
import types
import urllib2

try:
	import tidylib
except:
	tidylib = None

try:
	import mx.Tidy as mxtidy
except:
	mxtidy = None

# Turn off content-cleaning, since we want to see an approximation to the
# original content for hashing. rawdog will sanitise HTML when writing.
feedparser.RESOLVE_RELATIVE_URIS = 0
feedparser.SANITIZE_HTML = 0

# Disable microformat support, because it tends to return poor-quality data
# (e.g. identifying inappropriate things as enclosures), and it relies on
# BeautifulSoup which is unable to parse many feeds.
feedparser.PARSE_MICROFORMATS = 0

# This is initialised in main().
persister = None

system_encoding = None
def get_system_encoding():
	"""Get the system encoding."""
	return system_encoding

def safe_ftime(format, t):
github lemon24 / reader / src / reader / _parser.py View on Github external
if have_kwargs:

        def parse(*args: Any, **kwargs: Any) -> Any:
            return feedparser.parse(
                *args, resolve_relative_uris=True, sanitize_html=True, **kwargs
            )

        yield parse

    else:

        # This is in no way thread-safe, but what can you do?
        # TODO: Well, you could use locks to make it threadsafe...
        # https://docs.python.org/3/library/threading.html#lock-objects

        old_RESOLVE_RELATIVE_URIS = feedparser.RESOLVE_RELATIVE_URIS
        old_SANITIZE_HTML = feedparser.SANITIZE_HTML
        feedparser.RESOLVE_RELATIVE_URIS = True
        feedparser.SANITIZE_HTML = True

        try:
            yield feedparser.parse
        finally:
            feedparser.RESOLVE_RELATIVE_URIS = old_RESOLVE_RELATIVE_URIS
            feedparser.SANITIZE_HTML = old_SANITIZE_HTML
github rubys / venus / planet / __init__.py View on Github external
logger = logging.getLogger("planet.runner")
    logger.setLevel(logging.getLevelName(level))
    try:
        logger.warning
    except:
        logger.warning = logger.warn

    loggerParms = (level,format)
    return logger

sys.path.insert(1, os.path.join(os.path.dirname(__file__),'vendor'))

# Configure feed parser
import feedparser
feedparser.SANITIZE_HTML=1
feedparser.RESOLVE_RELATIVE_URIS=0