Tool to generate XPath

3

Hello, I'm doing a spider to capture with XPath some web data.

But the creation of xpath is a bit of work. Does anyone know of any way to train XPath? Example; I click 5 times on a link and some tool generates the xpath.

Any tips are welcome.

Thank you!

    
asked by anonymous 24.02.2015 / 19:07

4 answers

4

I compiled the answers found here:

link

"Chrome Dev Tools"

When using Chrome Dev Tools (you can access by right-clicking on an element and asking to "inspect element") you can right-click the element, then "Copy XPath".

Add-on for Chrome.

link

JavaScript Console

You can also use $ x in the Chrome javascript console.

ex: $ x ("// img")

XPather

I did not get to test, but this tool apparently seems to be what you want.

XPather

    
24.02.2015 / 19:34
3

Try the bookmarklet SelectorGadget .

It works like this: right after you hit, you click on something you want to capture. It generates a very generic selector, and highlights the captured sections in yellow.

From here on, you can refine the selection by: 1) clicking on a highlighted area to remove from the selection; or 2) by clicking on an undefined area to add the selection.

By default it generates a CSS selector, but has an XPath button to get the equivalent XPath expression.

    
03.03.2015 / 12:41
1

It has a add-on for Firefox that queries XPath on a page, called XPath Checker .

add-on page

    
24.02.2015 / 19:11
0

Install xmllint (tiny tool, usually already installed on linux) and play xpath:

xmllint --xpath '//symbol' file.xml

or, in the case of html:

xmllint --html --xpath '//table' file.html

or even

xmllint --html  --xpath '//a' 'http://a.b.c/index.html' > links.txt
    
24.02.2015 / 19:33