Skip to content

Instantly share code, notes, and snippets.

@frankcash
Created March 14, 2018 02:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frankcash/b2e768888858e4cc6c5769835abe19b6 to your computer and use it in GitHub Desktop.
Save frankcash/b2e768888858e4cc6c5769835abe19b6 to your computer and use it in GitHub Desktop.
Basic go-colly example
package main
import (
"fmt"
"github.com/gocolly/colly"
)
func main() {
c := colly.NewCollector()
// Find and visit all links
c.OnHTML("p.title", func(e *colly.HTMLElement) {
fmt.Println(e.Text)
})
c.OnRequest(func(r *colly.Request) {
fmt.Println("Visiting", r.URL)
})
c.Visit("reddit.com/r/programming")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment