My code ...
foo = fromstring(my_html)
he triggers this warning ...
UserWarning: No parser was explicitly specified, so I'm using the best available HTML parser for this system ("html.parser"). This usually isn't a problem, but if you run this code on another system, or in a different virtual environment, it may use a different parser and behave differently.
To get rid of this warning, change this:
BeautifulSoup([your markup])
to this:
BeautifulSoup([your markup], "html.parser")
markup_type=markup_type))
I tried passing a string to it 'html.parser', but it does not work, because it gives me an error saying that the string is not callable, so I tried html.parserand then I looked through the lxml module to see if I could find another parser and could not. I looked at python stdlib and saw that in version 2.7 there is one called HTMLParser, so I imported it and entered it beautifulsoup=HTMLParser, and that didn't work either.
Where fromstringdoes it indicate that I should switch to ?
EDIT added attempted solutions:
from lxml.html.soupparser import fromstring
wiktionary_page = fromstring(wiktionary_page.read(), features="html.parser" )
and this one
from lxml.html.soupparser import BeautifulSoup
wiktionary_page = fromstring(wiktionary_page.read(), beautifulsoup=lambda s: BeautifulSoup(s, "html.parser"))
source
share