You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
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) |