parent
8f5a2f4e5c
commit
5b529be289
@ -0,0 +1,17 @@
|
||||
from lxml import etree
|
||||
html="""
|
||||
<body>
|
||||
<div>
|
||||
<h1>Page Title</h1>
|
||||
<p>Some text.</p>
|
||||
<h2>Section 1</h2>
|
||||
<p>More text.</p>
|
||||
<h2>Section 2</h2>
|
||||
</div>
|
||||
</body>
|
||||
"""
|
||||
from lxml import etree
|
||||
selector = etree.HTML(html)
|
||||
#修改xpath表达式
|
||||
result = selector.xpath('//h2')
|
||||
print(result)
|
Loading…
Reference in new issue