1
0
Fork 0

Add: basic scraper that gets all urls from a wikipedia article

This commit is contained in:
Aroy-Art 2024-07-12 21:48:47 +02:00
parent 30a1f8052c
commit 1f63795e49
Signed by: Aroy
GPG key ID: DB9689E9391DD156

View file

@ -0,0 +1,20 @@
package main
import (
"fmt"
"github.com/gocolly/colly"
)
func main() {
c := colly.NewCollector(
colly.AllowedDomains("en.wikipedia.org"),
)
// Find and print all links
c.OnHTML(".mw-parser-output", func(e *colly.HTMLElement) {
links := e.ChildAttrs("a", "href")
fmt.Println(links)
})
c.Visit("https://en.wikipedia.org/wiki/Web_scraping")
}