Xpath提取一个标签里的所有文本 content = etree.HTML(text) h = content.xpath('//h1') h1 = h[0].xpath('string(.)').strip()