4 ms·
Could CSS selectors, with a few minor extensions, be just as good at XPath for this kind of thing? I guess a lot of the reason I find xpath frustrating is my u
by WhitneyLand 9y ago
Could CSS selectors, with a few minor extensions, be just as good at XPath for this kind of thing?
I guess a lot of the reason I find xpath frustrating is my usage frequency corresponds exactly to the time needed to forget the syntax and have to relearn/refresh it in my head.
If CSS selectors needed only a few enhancements to compete with XPath, it might be worth enhancing a selector library to enable quick ramp up speed for more web people.
- TACIXAT 9y agoIn the Chrome console you can right click elements in the sources tab and select Copy > Copy XPath. For example, your comment: //*[@id="15541111"]/td/table/tbody/tr/td[3]/div[2]
- tycho01 9y ago> If CSS selectors needed only a few enhancements to compete with XPath You may want to try ParslePy, it combines CSS/XPath functionality, allowing you to declaratively specify the selector paths in a JSON file. I just made a PR to allow YAML over JSON, but not sure if Pip picked up on it yet.
- tycho01 9y agoIt appears this is based on that cssselect library mentioned above, compiling CSS selectors to XPath. That is, performance should approximate XPath, while convenience should be higher.