Skip to content

Commit

Permalink
Merge pull request #95 from afeld/patch-1
Browse files Browse the repository at this point in the history
improve readme
  • Loading branch information
voxxit authored Jul 13, 2018
2 parents d1762b0 + edd3bed commit a1a8281
Showing 1 changed file with 32 additions and 23 deletions.
55 changes: 32 additions & 23 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,45 @@ This is a major rewrite from v0 in the following places:
- Serialization
- Some API adjustment

To install:
## Installation

- sudo apt-get install libxml2-dev
- go get github.com/moovweb/gokogiri
```bash
# Linux
sudo apt-get install libxml2-dev
# Mac
brew install libxml2

To run test:
go get github.com/moovweb/gokogiri
```

- go test github.com/moovweb/gokogiri/html
- go test github.com/moovweb/gokogiri/xml
## Running tests

Basic example:
```bash
go test github.com/moovweb/gokogiri/...
```

package main
## Basic example

import (
"net/http"
"io/ioutil"
"github.com/moovweb/gokogiri"
)
```go
package main

func main() {
// fetch and read a web page
resp, _ := http.Get("http://www.google.com")
page, _ := ioutil.ReadAll(resp.Body)
import (
"net/http"
"io/ioutil"
"github.com/moovweb/gokogiri"
)

// parse the web page
doc, _ := gokogiri.ParseHtml(page)
func main() {
// fetch and read a web page
resp, _ := http.Get("http://www.google.com")
page, _ := ioutil.ReadAll(resp.Body)

// perform operations on the parsed page -- consult the tests for examples
// parse the web page
doc, _ := gokogiri.ParseHtml(page)

// important -- don't forget to free the resources when you're done!
doc.Free()
}
// perform operations on the parsed page -- consult the tests for examples

// important -- don't forget to free the resources when you're done!
doc.Free()
}
```

0 comments on commit a1a8281

Please sign in to comment.