python 爬虫 怎么获取标签中的注释?我用得lxml解析html

 <span>当前第9127页&nbsp;<!--共136904条-->&nbsp;&nbsp;</span>

怎么才能获取注释里的值呢?

tree=etree.HTML(page)
pagenumber=tree.xpath(xpathStr)
for i in pagenumber:
           totalpage=filter(str.isdigit,str(i))

注释不属于xml格式了,你拿到span节点后获取它的内容,然后用字符串解析来获取注释。