其他分享
首页 > 其他分享> > lxml xpath用法

lxml xpath用法

作者:互联网

from lxml import  etree
import requests
hed={
   "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"
}
resp=requests.get("https://movie.douban.com/",headers=hed)
# print(resp.text)
et=etree.HTML(resp.text)
result=et.xpath("//div/a/@href")
result=et.xpath("//div/a/text()")
print(result)

 

标签:xpath,lxml,text,resp,用法,result,et
来源: https://blog.csdn.net/Swallow_shangtou/article/details/122472885