Re: [go-nuts] Re: http "alt" attribute value for img tag?

2018-04-21 Thread Nigel Tao
package main import ( "fmt" "log" "strings" "golang.org/x/net/html" ) func main() { const src = ` message ` doc, err := html.Parse(strings.NewReader(src)) if err != nil { log.Fatal(err) } var f func(*html.Node) f = func(n *html.Node) { if n.Type == html.ElementNode && n.Data == "img" {

[go-nuts] Re: http "alt" attribute value for img tag?

2018-04-19 Thread Timothy Raymond
You should have a look at http://go-colly.org . I've done scraping with html.Parse before, and I wish Colly existed when I did. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it,

[go-nuts] Re: http "alt" attribute value for img tag?

2018-04-19 Thread Victor L
i am trying html Parse method from "html"* package but can't find element "img" ...* *Any ideas?* var f func(*html.Node) f = func(n *html.Node) { if n.Type == html.ElementNode { //&& n.Data == "alt" { for _, a := range n.Attr { //if a.Key == "img" {

[go-nuts] Re: http "alt" attribute value for img tag?

2018-04-19 Thread matthewjuran
I would start by isolating the alt=“…” string with splits (https://golang.org/pkg/strings/#Split) then use Sscanf (https://golang.org/pkg/fmt/#Sscanf) to parse the number. There may be other approaches like regular expressions. Matt On Wednesday, April 18, 2018 at 9:52:28 PM UTC-5, l vic