Compare commits

..
7 Commits
Author SHA1 Message Date
Martin Angers d49fa5b2a1 update readme with new version 2013-04-26 19:44:22 -04:00
Martin Angers d84f346f92 update doc now that goquery is go-getable 2013-04-26 19:40:52 -04:00
Martin Angers f5309e0304 Merge pull request #7 from matrixik/master
Update exp/html import paths, closes #7
2013-04-26 16:32:17 -07:00
Martin Angers 4bdceda6d8 fix #8 2013-03-17 10:22:49 -04:00
Martin Angers fd221b178b install notes tweaked 2013-03-17 10:21:27 -04:00
Martin Angers ee5503bf12 update install instructions 2013-03-17 10:20:13 -04:00
Dobrosław Żybort 474b169363 Update exp/html import paths 2013-02-12 20:32:16 +01:00
13 changed files with 25 additions and 29 deletions
+2
View File
@@ -1,2 +1,4 @@
*.sublime-*
.DS_Store
*.swp
#*.*#
+12 -18
View File
@@ -1,6 +1,6 @@
# goquery - a little like that j-thing, only in Go
GoQuery brings a syntax and a set of features similar to [jQuery][] to the [Go language][go]. It is based on the [experimental html package][exphtml] and the CSS Selector library [cascadia][]. Since the experimental html parser returns tokens (nodes), and not a full-featured DOM object, jQuery's manipulation and modification functions have been left off (no point in modifying data in the parsed tree of the HTML, it has no effect).
GoQuery brings a syntax and a set of features similar to [jQuery][] to the [Go language][go]. It is based on the experimental html package and the CSS Selector library [cascadia][]. Since the experimental html parser returns tokens (nodes), and not a full-featured DOM object, jQuery's manipulation and modification functions have been left off (no point in modifying data in the parsed tree of the HTML, it has no effect).
Supported functions are query-oriented features (`hasClass()`, `attr()` and the likes), as well as traversing functions that make sense given what we have to work with. This makes GoQuery a great library for scraping web pages.
@@ -8,26 +8,21 @@ Syntax-wise, it is as close as possible to jQuery, with the same function names
## Installation
Since this library (and cascadia) depends on the experimental branch, this package must be installed first. Both GoQuery and Cascadia expect to find the experimental library with the `"exp/html"` import statement. To install it at this location, there's [this guide][wikiexp], but since late December 2012, Go tip has evolved and `"exp/html"` won't build with Go1.0.3. So the last valid revision that will build with Go1 is `d9ff34d481bc`. Just replace the second step in [the guide][wikiexp] with this command:
$ go get github.com/PuerkitoBio/goquery
hg clone -r d9ff34d481bc https://code.google.com/p/go go-exp
(optional) To run unit tests:
$ cd $GOPATH/src/github.com/PuerkitoBio/goquery
$ go test
The rest of the guide can be followed as-is (note that you can build just the `exp/html` package, you don't have to build `exp/...`).
(optional) To run benchmarks:
Once this is done, install GoQuery:
`go get github.com/PuerkitoBio/goquery`
To run unit tests, run this command in goquery's source directory (`$GOPATH/src/github.com/PuerkitoBio/goquery`):
`go test`
To run benchmarks, run this command in goquery's source directory:
`go test -bench=".*"`
$ cd $GOPATH/src/github.com/PuerkitoBio/goquery
$ go test -bench=".*"
## Changelog
* **v0.2.1** : Make go-getable, now that [go.net/html is Go1.0-compatible][gonet] (thanks to @matrixik for pointing this out).
* **v0.2.0** : Add support for negative indices in Slice(). **BREAKING CHANGE** `Document.Root` is removed, `Document` is now a `Selection` itself (a selection of one, the root element, just like `Document.Root` was before). Add jQuery's Closest() method.
* **v0.1.1** : Add benchmarks to use as baseline for refactorings, refactor Next...() and Prev...() methods to use the new html package's linked list features (Next/PrevSibling, FirstChild). Good performance boost (40+% in some cases).
* **v0.1.0** : Initial release.
@@ -102,11 +97,10 @@ The [BSD 3-Clause license][bsd], the same as the [Go language][golic]. Cascadia'
[jquery]: http://jquery.com/
[go]: http://golang.org/
[exphtml]: http://code.google.com/p/go/source/browse#hg%2Fsrc%2Fpkg%2Fexp
[cascadia]: http://code.google.com/p/cascadia/
[wikiexp]: http://code.google.com/p/go-wiki/wiki/InstallingExp
[bsd]: http://opensource.org/licenses/BSD-3-Clause
[golic]: http://golang.org/LICENSE
[caslic]: http://code.google.com/p/cascadia/source/browse/LICENSE
[doc]: http://go.pkgdoc.org/github.com/PuerkitoBio/goquery
[doc]: http://godoc.org/github.com/PuerkitoBio/goquery
[index]: http://api.jquery.com/index/
[gonet]: http://code.google.com/p/go/source/detail?r=f7f5159120f51ba0070774d3c5907969b5fe7858&repo=net
+1 -1
View File
@@ -1,7 +1,7 @@
package goquery
import (
"exp/html"
"code.google.com/p/go.net/html"
)
// First() reduces the set of matched elements to the first in the set.
+1 -1
View File
@@ -26,7 +26,7 @@ Package goquery implements features similar to jQuery, including the chainable
syntax, to manipulate and query an HTML document (the modification functions of jQuery are not included).
It depends on Go's experimental html package, which must be installed so that it
can be imported as "exp/html". See this tutorial on how to install it
can be imported as "code.google.com/p/go.net/html". See this tutorial on how to install it
accordingly: http://code.google.com/p/go-wiki/wiki/InstallingExp
It uses Cascadia as CSS selector (similar to Sizzle for jQuery). This dependency
+1 -1
View File
@@ -1,7 +1,7 @@
package goquery
import (
"exp/html"
"code.google.com/p/go.net/html"
)
// Add() adds the selector string's matching nodes to those in the current
+1 -1
View File
@@ -2,7 +2,7 @@ package goquery
import (
"code.google.com/p/cascadia"
"exp/html"
"code.google.com/p/go.net/html"
)
// Filter() reduces the set of matched elements to those that match the selector string.
+1 -1
View File
@@ -1,7 +1,7 @@
package goquery
import (
"exp/html"
"code.google.com/p/go.net/html"
"testing"
)
+1 -1
View File
@@ -2,7 +2,7 @@ package goquery
import (
"bytes"
"exp/html"
"code.google.com/p/go.net/html"
)
// Attr() gets the specified attribute's value for the first element in the
+1 -1
View File
@@ -2,7 +2,7 @@ package goquery
import (
"code.google.com/p/cascadia"
"exp/html"
"code.google.com/p/go.net/html"
"regexp"
"strings"
)
+1 -1
View File
@@ -2,7 +2,7 @@ package goquery
import (
"code.google.com/p/cascadia"
"exp/html"
"code.google.com/p/go.net/html"
)
type siblingType int
+1 -1
View File
@@ -1,7 +1,7 @@
package goquery
import (
"exp/html"
"code.google.com/p/go.net/html"
"net/http"
"net/url"
)
+1 -1
View File
@@ -1,7 +1,7 @@
package goquery
import (
"exp/html"
"code.google.com/p/go.net/html"
"fmt"
"os"
"testing"
+1 -1
View File
@@ -1,7 +1,7 @@
package goquery
import (
"exp/html"
"code.google.com/p/go.net/html"
)
func getChildren(n *html.Node) (result []*html.Node) {