1package main
2
3import (
4	"fmt"
5
6	"github.com/gocolly/colly/v2"
7)
8
9func main() {
10	// Instantiate default collector
11	c := colly.NewCollector()
12
13	// Before making a request put the URL with
14	// the key of "url" into the context of the request
15	c.OnRequest(func(r *colly.Request) {
16		r.Ctx.Put("url", r.URL.String())
17	})
18
19	// After making a request get "url" from
20	// the context of the request
21	c.OnResponse(func(r *colly.Response) {
22		fmt.Println(r.Ctx.Get("url"))
23	})
24
25	// Start scraping on https://en.wikipedia.org
26	c.Visit("https://en.wikipedia.org/")
27}
28