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.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay