Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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