大概率因爲頁面存在註釋,例如:
<!--[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