doc.Find("meta[property='og:image']").Each(func(i int, s *goquery.Selection) {
fmt.Fprintln("og data=", s)
})
Apparently not close enough to that j-thing.
How can you get the og data in a webpage from goquery?
doc.Find("meta[property='og:image']").Each(func(i int, s *goquery.Selection) {
fmt.Fprintln("og data=", s)
})
Apparently not close enough to that j-thing.
How can you get the og data in a webpage from goquery?
Just figured it out - hope this helps someone else out there
doc.Find("meta").Each(func(i int, s *goquery.Selection) {
op, _ := s.Attr("property")
con, _ := s.Attr("content")
if op == "og:image" {
fmt.Fprintln("og data=", con)
}
})
I was looking for this and I found an other way.
package main
import (
"fmt"
"net/http"
"github.com/PuerkitoBio/goquery"
)
func main() {
baseURL := `REPLACE_WITH_URL`
resp, err := http.Get(baseURL)
if err != nil {
fmt.Println(err)
return
}
doc, err := goquery.NewDocumentFromResponse(resp)
if err != nil {
fmt.Println(err)
return
}
imgURL, found := doc.Find(`meta[property="og:image"]`).Attr("content")
fmt.Println(imgURL, found)
}