This commit is contained in:
Martin Angers
2014-09-16 20:17:40 -04:00
parent 875035bc14
commit 10e92b83fb
2 changed files with 6 additions and 3 deletions
+3
View File
@@ -58,6 +58,8 @@ Please note that Cascadia's selectors do NOT necessarily match all supported sel
## Examples
See some tips and tricks in the [wiki][].
Taken (and adapted as if executed from outside the goquery package) from example_test.go:
```Go
@@ -102,3 +104,4 @@ The [BSD 3-Clause license][bsd], the same as the [Go language][golic]. Cascadia'
[index]: http://api.jquery.com/index/
[gonet]: http://code.google.com/p/go/source/detail?r=f7f5159120f51ba0070774d3c5907969b5fe7858&repo=net
[html]: http://godoc.org/code.google.com/p/go.net/html
[wiki]: https://github.com/PuerkitoBio/goquery/wiki/Tips-and-tricks
+3 -3
View File
@@ -2,7 +2,7 @@
## Handle Non-UTF8 html Pages
The `go.net/html` package used by `goquery` requires that the html document is UTF-8 encoded. When you know the encoding of the html page is not UTF-8, you can use the `iconv` package to convert it to UTF-8 (there are various implementation of the `iconv` API, see godoc.org for other options):
The `go.net/html` package used by `goquery` requires that the html document is UTF-8 encoded. When you know the encoding of the html page is not UTF-8, you can use the `iconv` package to convert it to UTF-8 (there are various implementation of the `iconv` API, see [godoc.org][iconv] for other options):
```
$ go get -u github.com/djimenez/iconv-go
@@ -46,7 +46,7 @@ You can find a code example using `otto` [in this gist][exotto]. Thanks to githu
## For Loop
If all you need is a normal `for` loop over all nodes in the current selection, where `Map` is not necessary, you can use the following:
If all you need is a normal `for` loop over all nodes in the current selection, where `Map/Each`-style iteration is not necessary, you can use the following:
```
sel := Doc().Find(".selector")
@@ -61,4 +61,4 @@ Thanks to github user @jmoiron.
[webloop]: https://github.com/sourcegraph/webloop
[otto]: https://github.com/robertkrimen/otto
[exotto]: https://gist.github.com/cryptix/87127f76a94183747b53
[iconv]: http://godoc.org/?q=iconv