logger.debug("Parsing response.text()=%d Bytes ...", len(response.text))
cookies.store(domain, response.cookies.get_dict())
+ # Init tag
+ tag = None
+
# Parse text
- meta = bs4.BeautifulSoup(
- response.text,
- "html.parser"
- )
- logger.debug("meta[]='%s'", type(meta))
- tag = meta.find("meta", attrs={"name": "csrf-token"})
+ try:
+ meta = bs4.BeautifulSoup(
+ response.text,
+ "html.parser"
+ )
+
+ logger.debug("meta[]='%s'", type(meta))
+ tag = meta.find("meta", attrs={"name": "csrf-token"})
+ except bs4.builder.ParserRejectedMarkup:
+ logger.warning("domain='%s' has returned invalid HTML markup", domain)
logger.debug("tag[%s]='%s'", type(tag), tag)
if tag is not None: