colly

gocollyApache-2.0活跃维护

Go 语言编写的高性能网页抓取与爬虫框架,提供简洁 API 处理请求、解析页面和并发抓取,适合快速搭建采集程序。

Elegant Scraper and Crawler Framework for Golang

v2.2.0发布于 2025-03-27 10:47 UTC25,587star +9 / 7 天1,855fork同步于 2026-11-10 17:22 UTC

怎么上手

由 README 提炼,执行前请确认
go get github.com/gocolly/colly/v2
硬件要求按 README 说明

README 未说明,纯 Go 库,无 GPU 或显存要求

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

Go 语言写的爬虫与抓取框架,用干净接口快速从网站提取结构化数据

Go 语言编写的高性能网页抓取与爬虫框架,提供简洁 API 处理请求、解析页面和并发抓取,适合快速搭建采集程序。

核心能力

  • 用 OnHTML 回调按 CSS 选择器提取页面数据
  • 按域名管理请求延迟与最大并发数
  • 自动处理 Cookie 与 Session
  • 支持同步、异步与并行抓取
  • 内置缓存、robots.txt 支持与分布式抓取

容易踩的坑

需自行安装 Go 工具链并初始化模块;README 未说明默认端口或其他额外依赖

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v2.2.0
  1. v2.2.0最新正式版2025-03-27 · 2025-03-27 10:47 UTC

    Tons of bug fixes & little improvements & updated dependencies

    What's Changed

  2. v2.1.02020-06-08 · 2020-06-08 23:47 UTC
    查看更新说明
    • HTTP tracing support
    • New callback: OnResponseHeader
    • Queue fixes
    • New collector option: Collector.CheckHead
    • Proxy fixes
    • Fixed POST revisit checking
    • Updated dependencies
  3. v2.0.02019-11-28 · 2019-11-28 12:29 UTC
    查看更新说明
    • Breaking change: Change Collector.RedirectHandler member to Collector.SetRedirectHandler function
    • Go module support
    • Collector.HasVisited method added to be able to check if an url has been visited
    • Collector.SetClient method introduced
    • HTMLElement.ChildTexts method added
    • New user agents
    • Multiple bugfixes
  4. v1.2.02019-02-13 · 2019-02-13 13:20 UTC
    查看更新说明
    • Compatibility with the latest htmlquery package
    • New request shortcut for HEAD requests
    • Check URL availibility before visiting
    • Fix proxy URL value
    • Request counter fix
    • Minor fixes in examples
  5. v1.1.02018-08-28 · 2018-08-28 16:55 UTC
    查看更新说明
    • Appengine integration takes context.Context instead of http.Request (API change)
    • Added "Accept" http header by default to every request
    • Support slices of pointers and structs in unmarshal
    • Fixed a race condition in queues
    • ForEachWithBreak method added to HTMLElement
    • Added a local file example
    • Support gzip decompression of response bodies
    • Don't share waitgroup when cloning a collector
    • Fixed instagram example

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Colly

    Lightning Fast and Elegant Scraping Framework for Gophers

    Colly provides a clean interface to write any kind of crawler/scraper/spider.

    With Colly you can easily extract structured data from websites, which can be used for a wide range of applications, like data mining, data processing or archiving.

    GoDoc Backers on Open Collective Sponsors on Open Collective build status report card view examples Code Coverage FOSSA Status Twitter URL

    Sponsors

    NodeMaven: The most efficient proxy provider for Web Scrapping and Automation with the Highest Quality IP on the market.

    Why NodeMaven?

    • 99.9% uptime
    • ZIP Targeting
    • IP filtering: all proxies have fraud score <97%
    • No KYC required
    • Unique free tools: Proxy Bandwidth Checker, Meta Tag Checker, IP Lookup and others!

    Special codes for Colly users:

    • COLLY35 - 35% off to Mobile and Residential Proxies
    • COLLY40 - 40% off to ISP (Static) Proxies

    NodeMaven

    SerpApi: Web Search API for your AI apps

    Access real-time data from search engines such as Google, Bing, YouTube, Amazon, and more in structured JSON or Markdown results via a simple API

    SerpApi

    SX.ORG: High-Speed High-Trust Proxies Built for Scraping & Automation at Any Scale

    • 240+ Locations to choose from
    • 120M+ IPs - Clean & Frequently Refreshed
    • All proxy types: mobile, residential, data-center
    • Extremely High-Trust - secure from bans
    • Flexible pricing –pay-as-you-goor unlimited trafficoptions

    Free trialfor new users - use promocode COLLY to claim 3GB of proxy

    SX.ORG

    Features

    • Clean API
    • Fast (>1k request/sec on a single core)
    • Manages request delays and maximum concurrency per domain
    • Automatic cookie and session handling
    • Sync/async/parallel scraping
    • Caching
    • Automatic encoding of non-unicode responses
    • Robots.txt support
    • Distributed scraping
    • Configuration via environment variables
    • Extensions

    Example

    
    import (
    	"fmt"
    
    	"github.com/gocolly/colly/v2"
    )
    
    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/")
    }
    

    See examples folder for more detailed examples.

    Installation

    go get github.com/gocolly/colly/v2

    Bugs

    Bugs or suggestions? Visit the issue tracker or join #colly on freenode

    Other Projects Using Colly

    Below is a list of public, open source projects that use Colly:

    If you are using Colly in a project please send a pull request to add it to the list.

    Contributors

    This project exists thanks to all the people who contribute. [Contribute].

    Backers

    Thank you to all our backers! 🙏 [Become a backer]

    Sponsors

    Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

    License

    FOSSA Status