9 lines
270 B
Python
9 lines
270 B
Python
from bs4 import BeautifulSoup, SoupStrainer, FeatureNotFound
|
|
|
|
def soupify(html, nohtml=False):
|
|
htm = html if nohtml else '<html><body>%s</body></html>'%(html)
|
|
try:
|
|
return BeautifulSoup(htm, 'lxml')
|
|
except FeatureNotFound:
|
|
return BeautifulSoup(htm, 'html.parser')
|