Created
March 14, 2018 02:36
-
-
Save frankcash/b2e768888858e4cc6c5769835abe19b6 to your computer and use it in GitHub Desktop.
Basic go-colly example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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