普通字符串?dāng)?shù)據(jù)需要將其初始化生成XPath解析對象才能利用XPath解析
from lxml import etree
text='''
<div>
<ul>
<li class="item-0"><a href="link1.html">第一個</a></li>
<li class="item-1"><a href="link2.html">second item</a></li>
<li class="item-0"><a href="link5.html">a屬性</a>
</ul>
</div>
'''
html=etree.HTML(text) #初始化生成一個XPath解析對象