Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve readme #95

Merged
merged 1 commit into from
Jul 13, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
}
```