import (
"log"
"net/http"
"astuart.co/goq"
)
// Structured representation for github file name table
type example struct {
Title string `goquery:"h1"`
Files []string `goquery:"table.files tbody tr.js-navigation-item td.content,text"`
}
func main() {
res, err := http.Get("https://github.com/andrewstuart/goq")
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
var ex example
err = goq.NewDecoder(res.Body).Decode(&ex)
if err != nil {
log.Fatal(err)
}
log.Println(ex.Title, ex.Files)
}
{{ .Emit }}
- Callable goquery methods with args, via reflection