Skip to content

API Reference ​

CyberGo html is a Go library for HTML content extraction. Its API has two entry points: package functions for one-off calls, and Processor instances that reuse the cache and accumulate state. The table below maps each component to its documentation.

ComponentDescriptionDocs
Package functionsConvenience functions for one-off callsPackage Functions
ProcessorProcessor instance that reuses resources and cacheProcessor
Reader modeWhole-page sectioned view with links preserved (ReadPage*)Reader Mode
ConfigConfiguration struct and presetsConfig
Output FormatsMarkdown and JSON outputOutput Formats
Link ExtractionStandalone link extraction APILink Extraction
Batch ProcessingConcurrent batch extractionBatch Processing
InterfacesExtractor, StatsProvider, and othersInterfaces
TypesResult, ReadResult, ImageInfo, and othersType Definitions
Constants & ErrorsDefaults and sentinel errorsConstants & Errors
SecurityContent cleaning, input limits, path safetySecurity
Audit SystemAudit pipeline and SinksAudit System

API Overview ​

Two Calling Modes ​

text
┌─────────────────────────────────────────┐
│         Package functions (one-off)     │
│  html.Extract(data) → *Result, error    │
│  Reuses Processor via sync.Pool         │
└─────────────────────────────────────────┘

┌─────────────────────────────────────────┐
│         Processor (instance mode)       │
│  p, _ := html.New(cfg)                  │
│  defer p.Close()                        │
│  result, err := p.Extract(data)         │
│  ✓ cache reuse  ✓ stats  ✓ audit log    │
└─────────────────────────────────────────┘

Function Naming Rules ​

PatternNamingExample
BaseExtract*Extract, ExtractText
From fileExtract*FromFileExtractFromFile
With contextExtract*WithContextExtractWithContext
From file + contextExtract*FromFileWithContextExtractFromFileWithContext
Reader modeReadPage*ReadPage, ReadPageToMarkdown
Reader mode (no links)ReadPage*TextReadPageToMarkdownText

ReadPage* is a separate family whose naming mirrors Extract*: *FromFile takes a path, WithContext makes the call cancellable, and *ToMarkdown/*ToMarkdownText return a single Markdown document directly.

Module Information ​

  • Module path: github.com/cybergodev/html
  • Go version: 1.26+
  • Dependencies: golang.org/x/net, golang.org/x/text

Core Type Quick Reference ​

TypeDescriptionDocs
ResultExtraction result (text, title, metadata, quality signals, media, statistics)Type Definitions
ReadResultReader-mode result (whole-page sections plus metadata)Reader Mode
PageSectionOne reader-mode section (kind, text, links, images)Reader Mode
ConfigUnified config struct and presetsConfig
ProcessorCore processing engine with cache and statisticsProcessor
StatisticsProcessing statistics (hits, errors, average time)Type Definitions
BatchResultBatch extraction resultBatch Processing
LinkResourceLink resource with type classificationLink Extraction
AuditEntryAudit log entryAudit System

Interface Quick Reference ​

InterfaceDescriptionDocs
ExtractorMain extraction interface, for decoupling and mocking (excludes ReadPage*)Interfaces
StatsProviderStatistics and cache management interfaceInterfaces
ScorerCustom content scoring algorithmInterfaces
ArticleFinderOptional: take over article-node selection in one passInterfaces
ContentNodeNode abstraction hiding the internal parser typeInterfaces
AuditSinkAudit log output targetInterfaces

Preset Configurations ​

Start from a preset and override fields; do not hand-write a zero-value config (Config{} fails Validate()):

PresetPurpose
DefaultConfig()General scenarios, balancing features and performance
TextOnlyConfig()No media or link information retained; those extractions are skipped
MarkdownConfig()Inline images and links in the body rendered as Markdown
HighSecurityConfig()High-security environments: tighter limits, shorter timeouts, audit enabled

See Config for details.

Find an API by Scenario ​

NeedRecommended APIDocs
Plain text onlyExtractText / Processor.ExtractTextPackage Functions
Whole-page text for an LLMReadPageToMarkdownReader Mode
Sectioned page view, filtered by the callerReadPage + ReadResult.SectionsReader Mode
Markdown outputExtractToMarkdown or MarkdownConfig()Output Formats
Extract all link resourcesExtractAllLinksLink Extraction
Concurrent batch processingExtractBatch / ExtractBatchFilesBatch Processing
Custom article detectionScorer interface + Config.Scorer (optionally ArticleFinder for single-pass selection)Interfaces
Audit security eventsAuditConfig + AuditSinkAudit System
High-frequency reuse + cachehtml.New() long-lived ProcessorProcessor