byteface / domonic

Create HTML with python 3 using a standard DOM API. Includes a python port of JavaScript for interoperability and tons of other cool features. A fast prototyping library.
https://domonic.readthedocs.io/
MIT License
129 stars 13 forks source link

xpath #41

Open byteface opened 2 years ago

byteface commented 2 years ago

I haven't even started to look into this. But figured i'd see if this 'up for grabs' label is worth trying.

https://up-for-grabs.net/#/

if anyone want to try xpath integration. Is there something in standard lib?. another small lib that works already with domonic? figured i'd start a discussion.

byteface commented 2 years ago

I found a lib that might be able to handle this. initial test seems to work. could be a fluke. if the Node class imitates etree Element seemed to do a match. https://github.com/sissaschool/elementpath

there's now an xpath branch. if it can pass a few more tests it should probably be included.

Does mean all of xpath needs stubbing out in webapi

byteface commented 2 years ago

elementpath now part of 8.4

the webapi will wrap it and have 2 options..

fix non underscore based accessors on attributes. or add the underscore to any '@' symbols inthe contructor of the XPATH expression. this will resolve the current bug that attributes still require the underscore even in the xpath xpression. it works fine but users won't know or expect that. so means fixing the bigger issue of attr lookups in the __get... dunders.

byteface commented 2 years ago

on the terminal i noticed you have to wrap the 2nd param in quotes as some chars bork... i.e...

domonic -x https://www.reddit.com/r/Python/ '//a[contains(@href, "http")]/@href'