Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
philbudne opened this issue Aug 19, 2024 · 0 comments
Open

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

philbudne opened this issue Aug 19, 2024 · 0 comments

Comments

@philbudne
Copy link
Collaborator

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant