DEV Community

ScrapeStorm
ScrapeStorm

Posted on

How to find XPath in Chrome

What is XPath?

XPath is a major element in the XSLT standard.

XPath stands for XML Path Language, it is a language for finding information in XML documents. It was originally used to search for XML documents, but it is also suitable for searching HTML documents. So when doing crawlers, you can use XPath to extract the corresponding information.

XPath uses “path like” syntax to identify and navigate nodes in an XML document.

In addition, it also provides more than 200 built-in functions for string, numeric, and time matching, as well as the processing of nodes and sequences. Almost all the nodes you want to locate can be selected using XPath.

How to get the XPath of the element?

  1. Open Chrome and find a website.

  2. Press F12 or right-click \”Inspect“\ or use the shortcut key Ctrl+Shift+I.

  3. Click the button in the upper left corner or press CTRL+SHIFT+C.

  4. After pressing the button and moving the mouse to the page, you will find that different colors appear in different locations.

  5. At this point we click any location, elements will change.

  6. Right-click in the area where the color changes, Copy->Copy XPath can copy XPath from the webpage, and then press CTRL+V to check whether the copy is successful.

This is the copied XPath

P.S. This operation is just the first step in getting web content or crawlers. If you need more, you can search for related tutorials.

Top comments (0)