Skip to content

Maybe pull HTML detection up from rss-fetcher? #3

Description

@philbudne

The rss-fetcher tries to generate a clearer error Exception for HTML by catching ExpatError exceptions and sniffing the top of the document:

    p = sitemap_parser.XMLSitemapParser(url, text)
    try:
        sitemap = p.sitemap()
    except ExpatError:          # try translateing ExpatError
        top = response.content[:1024].lower()
        if top.find(b'<!doctype') or top.find(b'<html'):
            raise Exception("html?")
        raise

Maybe pull this up into XMLSitemapParser.sitemap so that mc_sitemap_tools.discover (etc) can also benefit?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions