Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
scrape
✓ github.com/yhat/scrape
Find the first HTML node with a specific class attribute
package main
import (
"fmt"
"net/http"
"github.com/yhat/scrape"
"golang.org/x/net/html"
)
func main() {
resp, _ := http.Get("https://example.com")
root, _ := html.Parse(resp.Body)
matcher := func(n *html.Node) bool {
return scrape.Attr(n, "class") == "content"
}
node, _ := scrape.Find(root, matcher)
fmt.Println(scrape.Text(node))
}
Debug
Known issues
No known issues recorded.
Upgrade
Version history
0.0.0-20161128144610-24b7890b0945latest on pkg.go.dev
Audit
Dependencies
No dependency data recorded yet.