scrapy / parsel

Parsel lets you extract data from XML/HTML documents using XPath or CSS selectors
BSD 3-Clause "New" or "Revised" License
1.15k stars 146 forks source link

Get XPath from Selector #214

Open hans-friedhelm opened 3 years ago

hans-friedhelm commented 3 years ago

Is there a function to get the XPath string from an Selector object?

Gallaecio commented 3 years ago

There is no public property to read it. Would you like to make this a feature request to provide such a functionality?

As a workaround, you can read it from the private property _expr. But that property may be changed or removed in the future without a warning.

hans-friedhelm commented 3 years ago

Thank you very much for your helpful answer! This feature would be super helpful for my use case. Would you like to implement it?

Gallaecio commented 3 years ago

I’m not sure I’ll implement it myself, definitely not before #181 is merged, but it looks like a good improvement to have.