scrapy/docs/topics/xpath-tutorial.rst

582 B

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> </head>

XPath Tutorial

Welcome to the xpath tutorial. Have a look at this expression:

System Message: ERROR/3 (<stdin>, line 7)

Unknown directive type "xpathdemo".

.. xpathdemo:: //h2/a

    <html>
        <head>
            <title>My page</title>
        </head>
        <body>
            <h2>Welcome to my <a href="#">page</a></h2>
            <p>This is the first paragraph</p>.
            <!-- this is the end -->
        </body>
    </html>

And this one :-) :

System Message: ERROR/3 (<stdin>, line 22)

Unknown directive type "xpathdemo".

.. xpathdemo:: //h2

    <html>
      <h2>Welcome to my <a href="#">page</a></h2>
      <p>This is the first paragraph</p>.
      <!-- this is the end -->
    </html>
</html>