Go-colly meta tags

Tue, Jan 31, 2023 One-minute read

Go-colly meta tags

TIL how to scrape meta tags, specifically og:title and so on using go-colly.

c.OnHTML("html", func(e *colly.HTMLElement) {
  // note the use of backticks and double quotes - it has to be exactly like this
  title := e.ChildAttr(`meta[property="og:title"]`, "content")
  fmt.Println(title)
})

Tags:

#scraping #go #colly