parent
27d5e62e41
commit
4e77a55866
@ -1,18 +0,0 @@
|
||||
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)
|
||||
printf(selector)
|
Loading…
Reference in new issue