Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mkfsn/crepe
https://github.com/mkfsn/crepe
golang goquery jquery struct-tag
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/mkfsn/crepe
- Owner: mkfsn
- Created: 2020-02-29T02:59:08.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-03-08T12:37:18.000Z (almost 5 years ago)
- Last Synced: 2024-06-20T12:41:19.926Z (6 months ago)
- Topics: golang, goquery, jquery, struct-tag
- Language: Go
- Homepage: https://godoc.org/github.com/mkfsn/crepe
- Size: 22.5 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# crepe
crepe is a tool that helps you extract the data from ~~tons-of-layers~~ HTML in an easier way.
This uses a brilliant project called [goquery](https://github.com/PuerkitoBio/goquery) to extract the data.
# Example
By specifying some selectors in struct tags, crepe helps you unmarshal the data from HTML.
```go
html := `
Employees
Tony
Male
20
Mary
Female
23
`
var data struct {
Title string `crepe:"div#header>h1,text"`
Employees []*struct {
Id string `crepe:"attr=data-id"`
Name string `crepe:"td,:eq(0),text"`
Gender string `crepe:"td,:eq(1),text"`
Age int `crepe:"td,:eq(2),text"`
Role string `crepe:"attr=role"`
} `crepe:"table,:last,tbody>tr"`
}
if err := Unmarshal([]byte(html), &data); err != nil {
fmt.Printf("error: %v\n", err)
return
}
fmt.Printf("result: %v\n", data)
```