bs4不同解析器出来的结果不太一样
>>> from bs4 import BeautifulSoup
>>> t = '<s s="esprelig"/>)'
#html.parser
>>> BeautifulSoup(t,"html.parser")
<s s="esprelig"></s>)
#lxml
>>> BeautifulSoup(t,'lxml')
<html><body><s s="esprelig"></s>)</body></html>
#lxml-xml
>>> BeautifulSoup(t,["lxml-xml"])
<?xml version="1.0" encoding="utf-8"?>
<s s="esprelig"/>
#html5lib
>>> BeautifulSoup(t,"html5lib")
<html><head></head><body><s s="esprelig">)</s></body></html>
从测试结果来看,使用html5lib解析确实会出现你说的问题。我比较常用lxml,暂时还没遇到奇怪的问题