2021-04-04

xpath的使用

前xpath对象创立
一,解析html字符串html_string
from lxml import html
etree=html.etree
html_object=etree.parse(html_string)
#html_text=etree.tostring(html_objecct)
二,解析本地html字符串locad_html
from lxml import html
i=r"C:\L.html"
parser =html.etree.HTMLParser(encoding=“utf8”)
htmlelement = html.etree.parse(i, parser=parser)
#y=html.etree.tostring(htmlelement,encoding=“utf8”).decode(“utf8”)

上一篇:js 基础属性互转


下一篇:PATH模块