[ANN] GoQuery: jQuery-like features and syntax in Go

2,387 views
Skip to first unread message

victorcoder

unread,
Sep 5, 2012, 4:40:56 PM9/5/12
to golan...@googlegroups.com
Awesome! Thanks

Martin Angers

unread,
Sep 5, 2012, 8:32:33 PM9/5/12
to golan...@googlegroups.com
Just found out there was already a Go library called GoQuery (https://github.com/opesun/goquery), on http://go-lang.cat-v.org/pure-go-libs. It wasn't on Go Dashboard, and I don't think it was on go-lang.cat-v.org when I looked (I may have missed it though). Anyway, sorry about that, if it causes too much confusion I'll rename it. Not sure what the plans are for the other one, the approach is different (seems to include its own css selector, from a quick look).

Anyway, if the author sees this, I'm open to merge our efforts if doable, or simply rename mine, just contact me. Was definitely not intended.

Martin

Message has been deleted

Martin Angers

unread,
Sep 5, 2012, 8:49:56 PM9/5/12
to golan...@googlegroups.com
Thanks, didn't know about that feature.

Le mercredi 5 septembre 2012 20:43:15 UTC-4, Peter Russell a écrit :

On Wednesday, September 5, 2012 5:32:33 PM UTC-7, Martin Angers wrote:
It wasn't on Go Dashboard, and I don't think it was on go-lang.cat-v.org when I looked (I may have missed it though). 

The page http://go.pkgdoc.org/-/index is also a good page to check. 

Zippoxer

unread,
Sep 7, 2012, 7:48:09 AM9/7/12
to golan...@googlegroups.com
The newest exp/html is incompatible with the newest cascadia making your package not get-able. Had to clone revision e17cd42dcc09 of Go to get cascadia to compile.

On Wednesday, September 5, 2012 6:06:43 PM UTC+3, Martin Angers wrote:
Hi gophers,

I created a new library inspired by jQuery for server-side web page scraping. It offers most of jQuery's query/filter/traversal API with the same chainable syntax. It uses Go's experimental HTML package and the cascadia CSS Selector library. Since we don't have a full live DOM to work with, the modification (like addClass, text and val setters, etc.) functions of jQuery have not been implemented, but there's plenty of useful stuff to manipulate an HTML document.

It is available here, on github, with full docs and a working example:

Martin Angers

Martin Angers

unread,
Sep 7, 2012, 9:12:04 AM9/7/12
to golan...@googlegroups.com, dobro...@gmail.com
Allright,  thanks!

Le vendredi 7 septembre 2012 01:28:32 UTC-4, (inconnu) a écrit :
Martin,

I am the author of the other goquery package.
I see no problem here :).

Martin Angers

unread,
Sep 7, 2012, 9:17:56 AM9/7/12
to golan...@googlegroups.com
I'll check this next week,  thanks for pointing this out.

Andy Balholm

unread,
Sep 8, 2012, 1:39:41 PM9/8/12
to golan...@googlegroups.com
Somebody ("couchmoney") submitted a patch that fixes the problem with Cascadia. I have applied it, and it passes the tests again.

Martin Angers

unread,
Sep 9, 2012, 6:54:40 PM9/9/12
to golan...@googlegroups.com
...and I updated goquery to be up-to-date with the new exp/html. Everything should work as expected now.

Thanks,
Martin

Martin Angers

unread,
Sep 17, 2012, 11:20:55 AM9/17/12
to golan...@googlegroups.com
I pushed a new version of goquery (v0.1.1, the master branch is up-to-date) on the github repo, it's only under-the-covers work, but some decent performance gains in the Siblings(), Next...() and Prev...() methods (using the new html package's linked list features).

Martin Angers

unread,
Oct 14, 2012, 12:38:40 PM10/14/12
to golan...@googlegroups.com
I pushed a new commit that refactored the goquery.Document struct so that it is a goquery.Selection itself (using an anonymous embedded struct). So Document.Root is removed, all selection methods can be called directly on Document (this is obviously a breaking change).


Martin

Martin Angers

unread,
Nov 11, 2012, 9:42:24 PM11/11/12
to golan...@googlegroups.com
The v0.2 of goquery is now complete, with tests and benchmarks: https://github.com/puerkitobio/goquery/

jQuery's "Closest()" method has been added, as well as the previously mentioned refactor that makes the Document a Selection (Document.Root has been removed, Document IS Root). v0.2 also brings support for negative indices in the Slice() method, bringing the same behavior as jQuery.

As far as I'm concerned, this makes goquery feature-complete. Please use the github issues for feature requests or bugs.

Thanks,
Martin Angers
Reply all
Reply to author
Forward
0 new messages