Python使用Xpath方式获取网页元素定位

Python使用Xpath方式获取网页元素定位

#从lxml中导入etree
from lxml import etree

document = etree.HTML('<html><p>123</p></html>')
ele = document.xpath('/html/body/p/text()')
print(ele)

打印结果见下图
在这里插入图片描述

发布了7 篇原创文章 · 获赞 0 · 访问量 189

猜你喜欢

转载自blog.csdn.net/zhuan_long/article/details/104038622