Question

I am new to the XML Path Language. What I want is to use a tool to get the XPath to use in a script for scraping content.

For example:

On http://econpy.pythonanywhere.com/ex/001.html I want to get all buyer's names.

I have tried Firebug and the Chrome DevTools but they both seem to produce a path, which does not work for my purposes.

That is, I get /html/body/div[2]/div whereas it should be //div[@title="buyer-name"]/text().

(I used http://docs.python-guide.org/en/latest/scenarios/scrape/).

Any suggestions will be much appreciated.

Was it helpful?

Solution

There's a Firebug extension called FirePath, which enhances Firebug's features related to XPaths. Also there was a new feature implemented into Firebug lately, which allows to copy the minimal XPath.

Both of them create paths based on elements with IDs, though, so I created an enhancement request for Firebug to allow what you're asking for. And I also commented on an existing feature request for FirePath, which targets this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top