forked from go/golangs_learn
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
483 B
26 lines
483 B
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/gocolly/colly"
|
|
)
|
|
|
|
func main() {
|
|
// Create a collector
|
|
c := colly.NewCollector()
|
|
|
|
// Set HTML callback
|
|
// Won't be called if error occurs
|
|
c.OnHTML("*", func(e *colly.HTMLElement) {
|
|
fmt.Println(e)
|
|
})
|
|
|
|
// Set error handler
|
|
c.OnError(func(r *colly.Response, err error) {
|
|
fmt.Println("Request URL:", r.Request.URL, "failed with response:", r, "\nError:", err)
|
|
})
|
|
|
|
// Start scraping
|
|
c.Visit("https://definitely-not-a.website/")
|
|
}
|
|
|