1.lxml的安装
pip install lxml
2.导入lxml 的 etree 库 from lxml import etree
示例1
from lxml import etree
html = etree.HTML(response.text)
ret_list = html.xpath("xpath字符串")
示例2
href_list = html.xpath("//li[@class='item-1']/a/@href")
title_list = html.xpath("//li[@class='item-1']/a/text()")
标签:xpath,lxml,etree,示例,python,list,html,解析
From: https://www.cnblogs.com/zxyg/p/16836601.html