Colly
快速优雅的 Gophers 抓取框架
闪电般快速优雅的 Gophers 抓取框架
Colly 提供了一个干净的接口来编写任何类型的爬虫/scraper/spider。
使用 Colly,您可以轻松地从网站中提取结构化数据,这些数据可用于广泛的应用,如数据挖掘、数据处理或存档。
func main() {
c := colly.NewCollector()
// Find and visit all links
c.OnHTML("a[href]", func(e *colly.HTMLElement) {
e.Request.Visit(e.Attr("href"))
})
c.OnRequest(func(r *colly.Request) {
fmt.Println("Visiting", r.URL)
})
c.Visit("http://go-colly.org/")
}
有关更详细的示例,请参见示例文件夹。
将 colly 添加到您的go.mod
文件中:
module github.com/x/y
go 1.14
require (
github.com/gocolly/colly/v2 latest
)