don’t crash if there’s no XMLParsedAsHTMLWarning in BS4 (as we are trying to avoid them anyway

This commit is contained in:
Ploum 2023-10-05 14:27:58 +02:00
parent 4892b9e450
commit 5dd2238ef2
1 changed files with 7 additions and 3 deletions

View File

@ -36,9 +36,13 @@ try:
elif int(version[1]) == 9:
recent = version[2] >= 1
if recent:
from bs4 import XMLParsedAsHTMLWarning
import warnings
warnings.filterwarnings("ignore", category=XMLParsedAsHTMLWarning)
try:
#it looks like only recent versions of BS4 have the XMLParsed warning
from bs4 import XMLParsedAsHTMLWarning
import warnings
warnings.filterwarnings("ignore", category=XMLParsedAsHTMLWarning)
except:
pass
_HAS_SOUP = True
except ModuleNotFoundError:
_HAS_SOUP = False