How to use the mechanicalsoup.browser.Browser.__looks_like_html function in MechanicalSoup

To help you get started, we’ve selected a few MechanicalSoup 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 MechanicalSoup / MechanicalSoup / mechanicalsoup / browser.py View on Github external
def add_soup(response, soup_config):
        """Attaches a soup object to a requests response."""
        if ("text/html" in response.headers.get("Content-Type", "") or
                Browser.__looks_like_html(response)):
            response.soup = bs4.BeautifulSoup(response.content, **soup_config)
        else:
            response.soup = None