4 ms·
Show HN: GDOM – GraphQL for DOM traversing
- geniium 11y agoInteresting!
- lepunk 11y agovery nice. one thing i'm missing tho is a callback functionality. for example i did a quick scraper for tesco.com { page(url:"http://www.tesco.com/groceries/product/browse/default.aspx?N=4294793330&Ne=4294793660") { items: query(selector:"li.product") { title: text(selector:"span[data-title=true]") price: text(selector:"span.linePrice") url: attr(selector:"a:eq(0)", name:"href") } } } now the url field on the page is relative. it would be nice to have a callback param where i could execute a function on the result and prefix the url with "http://www.tesco.com" http://www.tesco.com" trying to make a pull request now
- dustingetz 11y agoThe DOM is a tree not a graph
- flaie 11y agoThis is a nice and interesting project! Obviously, I had to do it for HN: { page(url:"https://news.ycombinator.com") { items: query(selector:"tr.athing") { rank: text(selector:"td span.rank") title: text(selector:"td.title a") site: text(selector:"span.comhead a") url: attr(selector:"td.title a", name:"href") attrs: next { score: text(selector:"span.score") user: text(selector:"a:eq(0)") comments: text(selector:"a:eq(2)") } } } } In order to do that, I had to fork to add the support for "next" which will retrieve the immediately following sibling (ala jQuery), due to how HN is structured as table rows.
- syrusakbary 11y agoMakes sense! Merging soon :)