colly 高性能golang爬虫框架

fly1年前 ⋅ 1120 阅读

可能是最知名的 Go 爬虫框架。它拥有友好的 API 和丰富代码示例,短时间内即可上手。性能方面单核能达到 1K 请求/秒,还可以轻松管理请求方式、间隔和最大并发数,功能强大且优雅。

https://github.com/gocolly/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("https://go-colly.org/")
}


全部评论: 0

    相关推荐