goquery
jQuery-like HTML parsing and manipulation library for Go. Goquery wraps Go's golang.org/x/net/html package with a jQuery-inspired API — use CSS selectors to find elements, extract text, attributes, and HTML from web pages. The standard Go web scraping and HTML parsing library, used with colly and other Go scrapers for structured data extraction from HTML documents.
Score Breakdown
⚙ Agent Friendliness
🔒 Security
HTML parsing library — no network exposure. Parsing untrusted HTML is safe (no eval). No credential handling. Community-maintained.
⚡ Reliability
Best When
You're building Go scrapers or HTML processors and want jQuery CSS selector syntax for clean HTML data extraction.
Avoid When
The target page requires JavaScript execution — use chromedp or playwright-go for dynamic content.
Use Cases
- • Parse HTML responses from agent web crawlers to extract structured data using jQuery CSS selectors (Find('.price'), Attr('href'))
- • Build Go web scraping agents that extract product data, news articles, or document content from HTML pages
- • Process HTML documents in agent data pipelines — extract tables, lists, and structured content from HTML using CSS selectors
- • Validate and transform HTML content in agent document processing workflows using goquery's traversal API
- • Use goquery with colly for complete Go web scraping — colly handles HTTP crawling, goquery handles HTML data extraction
Not For
- • JavaScript-rendered pages — goquery only parses static HTML; use playwright-go or chromedp for JavaScript-rendered content
- • XML parsing — goquery targets HTML; use encoding/xml or etree for XML documents
- • Large-scale distributed scraping — goquery is a parsing library, not a crawling framework; use colly or scrapy for crawl orchestration
Interface
Authentication
HTML parsing library — no authentication. HTTP auth handled by the HTTP client making the request.
Pricing
BSD 2-clause license. Community-maintained.
Agent Metadata
Known Gotchas
- ⚠ Find() returns empty Selection (not nil) when no elements match — check Selection.Length() > 0 before calling text extraction methods; empty Selection returns empty string, not an error
- ⚠ goquery does NOT handle JavaScript rendering — websites that load content via JS return empty result sets; use chromedp or playwright-go for JS-rendered pages
- ⚠ HTML attribute values may be relative URLs — call Selection.Attr('href') and check if the URL is relative, then resolve with base URL before using for HTTP requests
- ⚠ goquery modifies the parsed DOM in memory — Find().Text() on a deeply nested structure can be slow for large documents; consider XPath via htmlquery for complex selectors
- ⚠ Malformed HTML is silently corrected by Go's x/net/html parser — the parsed DOM may differ from the raw HTML source; goquery operates on the corrected DOM, not the original source
- ⚠ Selection.Each() and Map() iterate in document order — for parallel extraction of large numbers of items, collect elements first then process concurrently rather than using Each()
Alternatives
Full Evaluation Report
Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for goquery.
Scores are editorial opinions as of 2026-03-06.