tree = etree.HTML(html)
tag = tree.xpath('//~~')[0]
text_tag = tag.xpath('string(.)').strip()
#只有这个方法最可靠

 

tree = etree.HTML(html)
node_list = tree.xpath('//div[contains(@id, "qiushi_tag")]')
#id属性中包含'qiushi_tag'
#<div class="article block untagged mb15 typs_long" id="qiushi_tag_120321510">

 

posted on 2018-05-16 09:29  math98  阅读(425)  评论(0)    收藏  举报