要先将源码etree
html = requests.get(=url=headers).text html = etree.HTML(html) html = etree.tostring(html=).decode() html.xpath('/html/body/div/ul/li/a[@href="link2.html"]/text()')
或将html.text转换为选择器对象
import parsel html = parsel.Selector(html_str) url = html.xpath('//div').extract()
评论 (0)