Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
foolin committed Apr 19, 2020
1 parent f83cd43 commit eab0add
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,7 @@ type Config struct {
```
[goquery selector]->[function]
```
example:



Example:
```go

type ExamData struct {
Expand All @@ -177,15 +174,15 @@ type ExamData struct {
- html()
- text()
- attr(name)
- attrInt(name, defaultValue)
- attrInt(name, defaultValue) //covert attr value to int
- outerHtml()
- value()
- value(name) //alias for `goquery.AttrOr("value", "")`

#### Extensions functions
- Markdown()
- UgcHtml()
- Markdown() //convert html to markdown format.
- UgcHtml() //sanitize html

extensions function need register:
Extensions function need register, like:
```go
import "github.com/foolin/pagser/extensions/markdown"

Expand All @@ -198,7 +195,7 @@ markdown.Register(p)

#### Write my function

Write function format:
**Function interface**
```go

type CallFunc func(node *goquery.Selection, args ...string) (out interface{}, err error)
Expand Down Expand Up @@ -287,7 +284,8 @@ func main(){

```

# Colly
# Colly Example

Work with colly:
```go

Expand All @@ -298,8 +296,8 @@ p := pagser.New()
collector.OnHTML("body", func(e *colly.HTMLElement) {
//data parser model
var page MyStruct
//parse html data
err := p.ParseSelection(&page, e.Dom)
//parse html data
err := p.ParseSelection(&page, e.Dom)

})

Expand Down

0 comments on commit eab0add

Please sign in to comment.