This may be due to an invalid character (due to encoding / decoding of the encoding), so BeautifulSoup has problems analyzing the input. I solve this by passing my string directly to BeautifulSoup without any encoding / decoding. In my case, I tried to convert UTF-16 to UTF-8 myself.
source share