大概率因为页面存在注释,例如:
<!--[if lte IE 8]>
<style index="index" data-compress="strip">
.s_form{top:260px}
</style>
<![endif]-->
<!--[if IE 8]>
<style index="index" data-compress="strip">
#u1 a.mnav,#u1 a.mnav:visited,#u1 a.lb,#u1 a.lb:visited,#u1 a.pf,#u1 a.pf:visited,#u1 a.bri,#u1 a.bri:visited{font-family:simsun;}
</style>
<![endif]-->
所以返回的列表中错误包含别的标签,而不是查找的标签。
但是标签的个数和页面对得上。
html.parser需要背这个锅。
使用html5lib,可以正常解析。但需要额外安装,pip install html5lib
beautifulsoup(markup,'html5lib')
lxml库也可以解决这个问题,但安装较慢比较拼人品。pip install lxml