diff --git a/X.py b/X.py new file mode 100644 index 0000000..1ffd621 --- /dev/null +++ b/X.py @@ -0,0 +1,17 @@ +from lxml import etree +html=""" + +
+

Page Title

+

Some text.

+

Section 1

+

More text.

+

Section 2

+
+ +""" +from lxml import etree +selector = etree.HTML(html) +#修改xpath表达式 +result = selector.xpath('//h2') +print(result)