Documentation
¶
Index ¶
- Constants
- Variables
- func ApplySchema(htmlStr string, schema Schema) (map[string]interface{}, error)
- func CanonicalizeURL(rawURL string) (string, error)
- func ChangeSignificance(oldContent, newContent string) int
- func CleanupMarkdown(md string) string
- func ContentChanged(oldContent, newContent string) bool
- func ConvertLinksToCitations(md string) string
- func CountMarkdownHeadings(content string) int
- func CountMarkdownLinks(content string) int
- func CountPattern(html string, pattern string) int
- func DedupeLines(content string) string
- func DetectBlocked(html string) bool
- func DetectJSChallenge(html string, contentType string, length int) bool
- func DetectLanguage(markdown string) string
- func DetectSPA(html string) (signals []string, isSPA bool)
- func ExtractFromHTML(html string, targetURL string) (string, error)
- func ExtractMetaAuthors(rawHTML string) []string
- func ExtractPDFText(body []byte) (out string, err error)
- func FetchBytes(ctx context.Context, rawURL string, opts FetchBytesOptions) ([]byte, http.Header, int, error)
- func LDJSONToMarkdown(blocks []LDJSONBlock) string
- func NearDuplicateScore(a, b string) int
- func PickCanonical(rawURL, html string) string
- func PreprocessHTML(htmlStr string) string
- func PreprocessHTMLWithURL(htmlStr string, _ *url.URL) string
- func PruneToContent(htmlStr string) string
- func QuickNeedsBrowser(html string) (needsBrowser bool, reason string)
- func RenderScrapeJSON(res *ScrapeResult) ([]byte, error)
- func RenderScrapeMarkdown(res *ScrapeResult) string
- func ResolveCanonicalLink(htmlStr string, baseURL string) string
- func ResolveUserAgent(s string) string
- func ResultToTEIXML(r Result) ([]byte, error)
- func SanitizeHTML(html string) string
- func SemanticFingerprint(content string) string
- func ShouldUseIndexFallback(readabilityResult Result, indexResult IndexPageResult) bool
- func StripInvisibleUnicode(text string) string
- func TruncateMarkdownAtParagraph(md string, maxTokens int) (string, bool)
- func WriteScrapeDirectory(res *ScrapeResult, dir string) ([]string, error)
- type BrowserDecision
- type CDNInfo
- type CacheAnalysis
- type CardItem
- type Chunk
- type ChunkConfig
- type ChunkStrategy
- type CommentRef
- type CorpusEntry
- type CrawlDelayCache
- func (c *CrawlDelayCache) GetDelay(ctx context.Context, domain string, userAgent string) time.Duration
- func (c *CrawlDelayCache) GetDelayWithScheme(ctx context.Context, domain string, userAgent string, scheme string) time.Duration
- func (c *CrawlDelayCache) IsAllowed(ctx context.Context, domain string, userAgent string, scheme string, ...) bool
- type DedupeOptions
- type DedupeResult
- type DedupeStats
- type DiskCache
- func (c *DiskCache) Get(url string, req *http.Request) (*cachedResponse, []byte, bool)
- func (c *DiskCache) GetStale(url string, req *http.Request) (*cachedResponse, []byte, bool, bool)
- func (c *DiskCache) GetStaleWithTolerance(url string, req *http.Request, tolerance time.Duration) (*cachedResponse, []byte, bool, bool, bool)
- func (c *DiskCache) Put(url string, req *http.Request, status int, headers http.Header, body []byte) error
- func (c *DiskCache) TouchByKey(key string) error
- type DomainRetry
- type ExtractionOutcome
- type FeedItem
- type FetchBytesOptions
- type FieldSpec
- type FlattenSitemapOptions
- type HostRateLimiter
- type IPResolver
- type ImageRef
- type IndexPageResult
- type LDJSONBlock
- type LinkRef
- type LinkRetention
- type Metadata
- type Options
- type OutputFormat
- type PageClass
- type PageGroup
- type PageObject
- type PagePerformance
- type PageProfile
- type ParseFeedOptions
- type PatternGroup
- type QualityMetrics
- type RankedSection
- type ResponseHeaders
- type Result
- func FromHTML(html string, targetURL string) Result
- func FromHTMLWithOptions(html string, targetURL string, opts Options) Result
- func FromResponse(resp *http.Response, targetURL string, start time.Time) (result Result)
- func FromURL(targetURL string) Result
- func FromURLContext(ctx context.Context, targetURL string, opts Options) Result
- func FromURLWithDedupe(targetURL string) Result
- func FromURLWithOptions(targetURL string, opts Options) Result
- type RetryEvent
- type SampleStrategy
- type Schema
- type ScrapeOptions
- type ScrapeResult
- type ScrapeSummary
- type SecurityPolicy
- type SiteInfo
- type SitemapEntry
- type SnapshotNode
- type SnapshotOptions
- type SplitConfig
- type SplitFile
- type TableKind
- type TableRef
- type TextFallbackResult
- type TraceInfo
- type TransportInfo
- type Validation
- type ViaHop
Constants ¶
View Source
const ( CDNCloudflare = "cloudflare" CDNCloudFront = "cloudfront" CDNFastly = "fastly" CDNAkamai = "akamai" CDNVarnish = "varnish" CDNNetlify = "netlify" CDNVercel = "vercel" CDNAzure = "azure" CDNGCP = "gcp" CDNFly = "fly" CDNDeno = "deno" CDNHeroku = "heroku" CDNRender = "render" CDNRailway = "railway" CDNShopify = "shopify" CDNSquarespace = "squarespace" CDNWix = "wix" CDNWebflow = "webflow" )
View Source
const ( DefaultClientTimeout = 30 * time.Second DefaultMaxRetryWait = 60 * time.Second DefaultTotalRetryTimeout = 120 * time.Second DefaultRetryBackoffBase = time.Second DefaultSitemapMaxDepth = 5 DefaultSitemapMaxURLs = 50_000 DefaultFeedMaxItems = 200 )
View Source
const ( DefaultScrapeMaxPages = 50 DefaultScrapeMaxPerPattern = 8 DefaultScrapeTimeout = 60 * time.Second )
View Source
const DefaultAccept = "text/markdown, text/html;q=0.9, application/xhtml+xml;q=0.8, application/xml;q=0.7, */*;q=0.1"
View Source
const DefaultAcceptEncoding = "gzip, deflate, br, zstd"
View Source
const DefaultUserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
Variables ¶
View Source
var ( ErrSecurityScheme = errors.New("scheme not allowed by security policy") ErrSecurityDomain = errors.New("host blocked by security policy") ErrPrivateIPBlocked = errors.New("target resolves to a private/internal IP") ErrSecurityResolve = errors.New("could not resolve target host") ErrResponseTooLarge = errors.New("response exceeds the configured size cap") ErrDecompressTooLarge = errors.New("decompressed body exceeds the configured size cap") )
View Source
var ErrBlockedByRobots = errors.New("blocked by robots.txt")
View Source
var ErrInvalidBaseURL = errors.New("seaportal: ScrapeOptions.BaseURL is not a valid absolute URL")
View Source
var ErrMissingBaseURL = errors.New("seaportal: ScrapeOptions.BaseURL is required")
View Source
var ErrNeedsBrowser = errors.New("needs-browser")
Functions ¶
func CanonicalizeURL ¶
func ChangeSignificance ¶
func CleanupMarkdown ¶
func ContentChanged ¶
func ConvertLinksToCitations ¶
func CountMarkdownHeadings ¶
func CountMarkdownLinks ¶
func CountPattern ¶
func DedupeLines ¶
func DetectBlocked ¶
func DetectLanguage ¶
func ExtractMetaAuthors ¶
func ExtractPDFText ¶
func FetchBytes ¶
func LDJSONToMarkdown ¶
func LDJSONToMarkdown(blocks []LDJSONBlock) string
func NearDuplicateScore ¶
func PickCanonical ¶
func PreprocessHTML ¶
func PruneToContent ¶
func QuickNeedsBrowser ¶
func RenderScrapeJSON ¶ added in v0.2.0
func RenderScrapeJSON(res *ScrapeResult) ([]byte, error)
func RenderScrapeMarkdown ¶ added in v0.2.0
func RenderScrapeMarkdown(res *ScrapeResult) string
func ResolveCanonicalLink ¶
func ResolveUserAgent ¶
func ResultToTEIXML ¶
func SanitizeHTML ¶
func SemanticFingerprint ¶
func ShouldUseIndexFallback ¶
func ShouldUseIndexFallback(readabilityResult Result, indexResult IndexPageResult) bool
func StripInvisibleUnicode ¶
func WriteScrapeDirectory ¶ added in v0.2.0
func WriteScrapeDirectory(res *ScrapeResult, dir string) ([]string, error)
Types ¶
type BrowserDecision ¶
type BrowserDecision string
const ( DecisionStaticHighConfidence BrowserDecision = "static-high-confidence" DecisionStaticOK BrowserDecision = "static-ok" DecisionStaticCaution BrowserDecision = "static-caution" DecisionBrowserNeeded BrowserDecision = "browser-needed" DecisionBlocked BrowserDecision = "blocked" DecisionAuthRequired BrowserDecision = "auth-required" DecisionUnreachable BrowserDecision = "unreachable" DecisionNotFound BrowserDecision = "not-found" DecisionUnsupported BrowserDecision = "unsupported" )
type CacheAnalysis ¶ added in v0.2.0
type CacheAnalysis struct {
CacheAge int `json:"cacheAge,omitempty"`
CacheMaxAge int `json:"cacheMaxAge,omitempty"`
CacheSMaxAge int `json:"cacheSMaxAge,omitempty"`
CacheFreshness int `json:"cacheFreshness,omitempty"`
CacheIsStale bool `json:"cacheIsStale,omitempty"`
CacheStaleWhileRevalidate int `json:"cacheStaleWhileRevalidate,omitempty"`
CacheStaleIfError int `json:"cacheStaleIfError,omitempty"`
CacheHasSWR bool `json:"cacheHasSwr,omitempty"`
CDNEdgeLocation string `json:"cdnEdgeLocation,omitempty"`
CacheMustRevalidate bool `json:"cacheMustRevalidate,omitempty"`
CacheProxyRevalidate bool `json:"cacheProxyRevalidate,omitempty"`
CacheNoCache bool `json:"cacheNoCache,omitempty"`
CacheNoCacheFields []string `json:"cacheNoCacheFields,omitempty"`
CacheNoStore bool `json:"cacheNoStore,omitempty"`
CacheImmutable bool `json:"cacheImmutable,omitempty"`
CachePrivate bool `json:"cachePrivate,omitempty"`
CachePublic bool `json:"cachePublic,omitempty"`
CachePolicySummary string `json:"cachePolicySummary,omitempty"`
CachePolicyScore int `json:"cachePolicyScore,omitempty"`
EffectiveCDNTTL int `json:"effectiveCdnTtl,omitempty"`
CacheRecommendations []string `json:"cacheRecommendations,omitempty"`
CDNOptimizationIssues []string `json:"cdnOptimizationIssues,omitempty"`
SurrogateMaxAge int `json:"surrogateMaxAge,omitempty"`
SurrogateStaleWhileRevalidate int `json:"surrogateStaleWhileRevalidate,omitempty"`
SurrogateStaleIfError int `json:"surrogateStaleIfError,omitempty"`
SurrogateNoStore bool `json:"surrogateNoStore,omitempty"`
SurrogateNoStoreRemote bool `json:"surrogateNoStoreRemote,omitempty"`
RequestID string `json:"requestId,omitempty"`
CacheHitRateEstimate string `json:"cacheHitRateEstimate,omitempty"`
BandwidthSavingsLevel string `json:"bandwidthSavingsLevel,omitempty"`
CacheCostAnalysis string `json:"cacheCostAnalysis,omitempty"`
}
type Chunk ¶
type Chunk struct {
Index int `json:"index"`
Heading string `json:"heading,omitempty"`
Text string `json:"text"`
Tokens int `json:"tokens"`
}
func ChunkMarkdown ¶
func ChunkMarkdown(md string, cfg ChunkConfig) []Chunk
type ChunkConfig ¶
type ChunkConfig struct {
Strategy ChunkStrategy
Size int
Overlap int
}
func ParseChunkConfig ¶
func ParseChunkConfig(s string) (ChunkConfig, error)
func (ChunkConfig) String ¶
func (c ChunkConfig) String() string
type ChunkStrategy ¶
type ChunkStrategy int
const ( ChunkOff ChunkStrategy = iota ChunkHeading ChunkSentence ChunkWindow )
type CommentRef ¶
type CommentRef struct {
Author string `json:"author,omitempty"`
Text string `json:"text"`
Timestamp string `json:"timestamp,omitempty"`
}
func ExtractComments ¶
func ExtractComments(htmlStr string, _ string) []CommentRef
type CorpusEntry ¶
func LoadCorpus ¶
func LoadCorpus(path string) ([]CorpusEntry, error)
type CrawlDelayCache ¶
type CrawlDelayCache struct {
// contains filtered or unexported fields
}
func NewCrawlDelayCache ¶
func NewCrawlDelayCache() *CrawlDelayCache
func (*CrawlDelayCache) GetDelayWithScheme ¶
type DedupeOptions ¶
type DedupeOptions struct {
MinBlockLen int
NormalizeWhitespace bool
CaseSensitive bool
NearDup bool
}
func DefaultDedupeOptions ¶
func DefaultDedupeOptions() DedupeOptions
type DedupeResult ¶
type DedupeResult struct {
Content string `json:"content,omitempty"`
OriginalBlocks int `json:"originalBlocks,omitempty"`
UniqueBlocks int `json:"uniqueBlocks,omitempty"`
DuplicatesFound int `json:"duplicatesFound,omitempty"`
DuplicateSignals []string `json:"duplicateSignals,omitempty"`
NearDuplicatesFound int `json:"nearDuplicatesFound,omitempty"`
NearDuplicateSignals []string `json:"nearDuplicateSignals,omitempty"`
}
func Dedupe ¶
func Dedupe(content string) DedupeResult
func DedupeWithOptions ¶
func DedupeWithOptions(content string, opts DedupeOptions) DedupeResult
type DedupeStats ¶ added in v0.2.0
type DedupeStats struct {
DedupeApplied bool `json:"dedupeApplied,omitempty"`
DuplicatesRemoved int `json:"duplicatesRemoved,omitempty"`
DuplicateSignals []string `json:"duplicateSignals,omitempty"`
NearDuplicatesRemoved int `json:"nearDuplicatesRemoved,omitempty"`
NearDuplicateSignals []string `json:"nearDuplicateSignals,omitempty"`
OriginalBlockCount int `json:"originalBlockCount,omitempty"`
UniqueBlockCount int `json:"uniqueBlockCount,omitempty"`
}
type DiskCache ¶
type DiskCache struct {
// contains filtered or unexported fields
}
func (*DiskCache) GetStaleWithTolerance ¶
func (*DiskCache) TouchByKey ¶
type DomainRetry ¶
type ExtractionOutcome ¶
type ExtractionOutcome string
const ( OutcomeExtract ExtractionOutcome = "extract" OutcomeExtractWarning ExtractionOutcome = "extract-with-warning" OutcomeFailFast ExtractionOutcome = "fail-fast" OutcomeNeedsBrowser ExtractionOutcome = "needs-browser" )
type FeedItem ¶
type FetchBytesOptions ¶
type FlattenSitemapOptions ¶
type HostRateLimiter ¶
type HostRateLimiter struct {
// contains filtered or unexported fields
}
func NewHostRateLimiter ¶
func NewHostRateLimiter() *HostRateLimiter
type IPResolver ¶ added in v0.2.0
type ImageRef ¶
type ImageRef struct {
Src string `json:"src"`
Alt string `json:"alt,omitempty"`
Srcset string `json:"srcset,omitempty"`
Title string `json:"title,omitempty"`
}
func ExtractImages ¶
type IndexPageResult ¶
type IndexPageResult struct {
IsIndexPage bool
Items []CardItem
Markdown string
Confidence int
ArticleCount int
HeadlineCount int
}
func DetectIndexPage ¶
func DetectIndexPage(htmlStr string) IndexPageResult
type LDJSONBlock ¶
type LDJSONBlock struct {
Type string `json:"type,omitempty"`
Headline string `json:"headline,omitempty"`
Description string `json:"description,omitempty"`
Author string `json:"author,omitempty"`
DatePub string `json:"datePublished,omitempty"`
Publisher string `json:"publisher,omitempty"`
URL string `json:"url,omitempty"`
Keywords string `json:"keywords,omitempty"`
Language string `json:"inLanguage,omitempty"`
Section string `json:"articleSection,omitempty"`
Body string `json:"articleBody,omitempty"`
}
func ExtractLDJSON ¶
func ExtractLDJSON(html string) []LDJSONBlock
type LinkRef ¶
type LinkRef struct {
Href string `json:"href"`
Text string `json:"text,omitempty"`
Rel string `json:"rel,omitempty"`
}
func ExtractLinks ¶
type LinkRetention ¶
type LinkRetention int
const ( LinkRetentionAll LinkRetention = iota LinkRetentionNone LinkRetentionText )
func ParseLinkRetention ¶
func ParseLinkRetention(s string) (LinkRetention, error)
func (LinkRetention) String ¶
func (m LinkRetention) String() string
type Metadata ¶
type Metadata struct {
Author string
PublishedDate string
Language string
Section string
Description string
ImageURL string
OGType string
Keywords string
}
func ExtractMetadata ¶
type Options ¶
type Options struct {
FailFast bool
FastMode bool
ProbeSearch bool
NoPooling bool
MaxRetries int
MaxRetryWait time.Duration
TotalRetryTimeout time.Duration
ClientTimeout time.Duration
RetryBackoffBase time.Duration
HeadPreflight bool
ContentTypePreflight bool
RetryLogger func(event RetryEvent)
DomainRetryConfig map[string]DomainRetry
UserAgent string
DomainUserAgent map[string]string
DomainTimeout map[string]time.Duration
RespectCrawlDelay bool
RespectRobots bool
CrawlDelayCache *CrawlDelayCache
RateLimit time.Duration
RateLimiter *HostRateLimiter
RequestID string
SendRequestID bool
Dedupe bool
NoNearDedupe bool
WithLinks bool
WithImages bool
WithTables bool
WithComments bool
Citations bool
LinkRetention LinkRetention
Chunk ChunkConfig
SelectCSS string
StripCSS string
MaxTokens int
HeadOnly bool
NoPruneFallback bool
Proxy string
CacheDir string
CacheTTL time.Duration
CacheStaleTolerance time.Duration
NoCache bool
NoPDF bool
SchemaPath string
Schema *Schema
Query string
TopN int
FilterByQuery bool
SplitOut string
SplitBytes int
Transport http.RoundTripper
Security *SecurityPolicy
Context context.Context
}
type OutputFormat ¶ added in v0.2.0
type OutputFormat string
const ( OutputJSON OutputFormat = "json" OutputMarkdown OutputFormat = "md" OutputDirectory OutputFormat = "directory" )
type PageGroup ¶ added in v0.2.0
type PageGroup struct {
Pattern string `json:"pattern"`
TotalInSitemap int `json:"totalInSitemap"`
Sampled int `json:"sampled"`
Pages []PageObject `json:"pages"`
}
type PageObject ¶ added in v0.2.0
type PageObject struct {
URL string `json:"url"`
Title string `json:"title"`
Status int `json:"status"`
Meta map[string]string `json:"meta,omitempty"`
Markdown string `json:"markdown"`
Schema []map[string]any `json:"schema,omitempty"`
Performance *PagePerformance `json:"performance,omitempty"`
ContentType string `json:"contentType"`
InternalLinks int `json:"internalLinks"`
ExternalLinks int `json:"externalLinks"`
Error string `json:"error,omitempty"`
}
type PagePerformance ¶ added in v0.2.0
type PageProfile ¶
type PageProfile struct {
Class PageClass `json:"class"`
Outcome ExtractionOutcome `json:"outcome"`
Decision BrowserDecision `json:"decision"`
BrowserRecommended bool `json:"browserRecommended"`
Reasons []string `json:"reasons"`
Confidence int `json:"confidence"`
Trustworthy bool `json:"trustworthy"`
}
func ClassifyPage ¶
func ClassifyPage(result Result) PageProfile
func (PageProfile) String ¶
func (p PageProfile) String() string
type ParseFeedOptions ¶
type PatternGroup ¶ added in v0.2.0
type QualityMetrics ¶
func ComputeQuality ¶
func ComputeQuality(markdown string) QualityMetrics
type RankedSection ¶
type RankedSection struct {
Score float64 `json:"score"`
Heading string `json:"heading,omitempty"`
Text string `json:"text"`
Tokens int `json:"tokens"`
}
func RankSections ¶
func RankSections(content, query string, k1, b float64, topN int) []RankedSection
type ResponseHeaders ¶ added in v0.2.0
type ResponseHeaders struct {
ResponseETag string `json:"responseEtag,omitempty"`
ResponseLastModified string `json:"responseLastModified,omitempty"`
ResponseContentEncoding string `json:"responseContentEncoding,omitempty"`
ResponseServer string `json:"responseServer,omitempty"`
ResponseXForwardedFor string `json:"responseXForwardedFor,omitempty"`
RequestAcceptEncoding string `json:"requestAcceptEncoding,omitempty"`
TTFBMs int64 `json:"ttfbMs,omitempty"`
DownloadMs int64 `json:"downloadMs,omitempty"`
ResponseVia string `json:"responseVia,omitempty"`
ResponseConnection string `json:"responseConnection,omitempty"`
ResponseAge string `json:"responseAge,omitempty"`
ResponseCacheControl string `json:"responseCacheControl,omitempty"`
ResponseXCache string `json:"responseXCache,omitempty"`
ResponseVary string `json:"responseVary,omitempty"`
ResponseXCacheHits string `json:"responseXCacheHits,omitempty"`
ResponseSurrogateControl string `json:"responseSurrogateControl,omitempty"`
ResponseCFCacheStatus string `json:"responseCfCacheStatus,omitempty"`
ResponseXServedBy string `json:"responseXServedBy,omitempty"`
ResponseXFastlyRequestID string `json:"responseXFastlyRequestId,omitempty"`
ResponseXAkamaiTransformed string `json:"responseXAkamaiTransformed,omitempty"`
ResponseXAkamaiSessionInfo string `json:"responseXAkamaiSessionInfo,omitempty"`
ResponseXAkamaiRequestID string `json:"responseXAkamaiRequestId,omitempty"`
ResponseXRequestId string `json:"responseXRequestId,omitempty"`
ResponseXCorrelationId string `json:"responseXCorrelationId,omitempty"`
ResponseXVarnish string `json:"responseXVarnish,omitempty"`
ResponseXCDN string `json:"responseXCdn,omitempty"`
ResponseXTraceId string `json:"responseXTraceId,omitempty"`
ResponseXB3TraceId string `json:"responseXB3TraceId,omitempty"`
ResponseXB3SpanId string `json:"responseXB3SpanId,omitempty"`
ResponseXB3ParentSpanId string `json:"responseXB3ParentSpanId,omitempty"`
ResponseXB3Sampled string `json:"responseXB3Sampled,omitempty"`
ResponseB3 string `json:"responseB3,omitempty"`
ResponseTraceparent string `json:"responseTraceparent,omitempty"`
ResponseTracestate string `json:"responseTracestate,omitempty"`
ResponseXAmznTraceId string `json:"responseXAmznTraceId,omitempty"`
TraceInfo
ResponseNEL string `json:"responseNel,omitempty"`
ResponseReportTo string `json:"responseReportTo,omitempty"`
ResponsePermissionsPolicy string `json:"responsePermissionsPolicy,omitempty"`
ResponseExpectCT string `json:"responseExpectCt,omitempty"`
ResponseFeaturePolicy string `json:"responseFeaturePolicy,omitempty"`
ResponseReportingEndpoints string `json:"responseReportingEndpoints,omitempty"`
ResponseCSP string `json:"responseCsp,omitempty"`
ResponseCSPReportOnly string `json:"responseCspReportOnly,omitempty"`
ResponseCORP string `json:"responseCorp,omitempty"`
ResponseCOEP string `json:"responseCoep,omitempty"`
ResponseCOOP string `json:"responseCoop,omitempty"`
ResponseHSTS string `json:"responseHsts,omitempty"`
ResponseXContentTypeOptions string `json:"responseXContentTypeOptions,omitempty"`
ResponseXFrameOptions string `json:"responseXFrameOptions,omitempty"`
ResponseReferrerPolicy string `json:"responseReferrerPolicy,omitempty"`
ResponseXXSSProtection string `json:"responseXXssProtection,omitempty"`
ResponseXPermittedCrossDomainPolicies string `json:"responseXPermittedCrossDomainPolicies,omitempty"`
ResponseXDownloadOptions string `json:"responseXDownloadOptions,omitempty"`
ResponseClearSiteData string `json:"responseClearSiteData,omitempty"`
ResponseTimingAllowOrigin string `json:"responseTimingAllowOrigin,omitempty"`
ResponseOriginAgentCluster string `json:"responseOriginAgentCluster,omitempty"`
ResponseDocumentPolicy string `json:"responseDocumentPolicy,omitempty"`
ResponseAcceptCH string `json:"responseAcceptCH,omitempty"`
ResponseSecCHUA string `json:"responseSecChUa,omitempty"`
ResponseSecCHUAMobile string `json:"responseSecChUaMobile,omitempty"`
ResponseSecCHUAPlatform string `json:"responseSecChUaPlatform,omitempty"`
ResponseSecCHUAFullVersionList string `json:"responseSecChUaFullVersionList,omitempty"`
ResponseSecCHPrefersColorScheme string `json:"responseSecChPrefersColorScheme,omitempty"`
ResponseCriticalCH string `json:"responseCriticalCh,omitempty"`
ResponseCOEPReportOnly string `json:"responseCoepReportOnly,omitempty"`
ResponseCOOPReportOnly string `json:"responseCoopReportOnly,omitempty"`
ResponseDocumentPolicyReportOnly string `json:"responseDocumentPolicyReportOnly,omitempty"`
ResponseSourceMap string `json:"responseSourceMap,omitempty"`
ResponseAccessControlAllowOrigin string `json:"responseAccessControlAllowOrigin,omitempty"`
ResponseAccessControlAllowMethods string `json:"responseAccessControlAllowMethods,omitempty"`
ResponseAccessControlAllowHeaders string `json:"responseAccessControlAllowHeaders,omitempty"`
ResponseAccessControlAllowCredentials string `json:"responseAccessControlAllowCredentials,omitempty"`
ResponseAccessControlExposeHeaders string `json:"responseAccessControlExposeHeaders,omitempty"`
ResponseAccessControlMaxAge string `json:"responseAccessControlMaxAge,omitempty"`
ResponseLink string `json:"responseLink,omitempty"`
LLMsTxtURL string `json:"llmsTxtUrl,omitempty"`
LDJSONBlocks []LDJSONBlock `json:"ldJsonBlocks,omitempty"`
HasLLMContent bool `json:"hasLlmContent,omitempty"`
ResponseXRobotsTag string `json:"responseXRobotsTag,omitempty"`
ResponseContentDisposition string `json:"responseContentDisposition,omitempty"`
ResponseXContentDuration string `json:"responseXContentDuration,omitempty"`
ResponseRefresh string `json:"responseRefresh,omitempty"`
ResponseContentLanguage string `json:"responseContentLanguage,omitempty"`
ResponseXUACompatible string `json:"responseXUaCompatible,omitempty"`
ResponseAcceptRanges string `json:"responseAcceptRanges,omitempty"`
ResponseTransferEncoding string `json:"responseTransferEncoding,omitempty"`
ResponseContentRange string `json:"responseContentRange,omitempty"`
ResponsePragma string `json:"responsePragma,omitempty"`
ResponseXPoweredBy string `json:"responseXPoweredBy,omitempty"`
ResponseXAspNetVersion string `json:"responseXAspNetVersion,omitempty"`
ResponseXAspNetMvcVersion string `json:"responseXAspNetMvcVersion,omitempty"`
ResponseServerTiming string `json:"responseServerTiming,omitempty"`
ResponseXGenerator string `json:"responseXGenerator,omitempty"`
ResponseXRuntime string `json:"responseXRuntime,omitempty"`
ResponseXDrupalCache string `json:"responseXDrupalCache,omitempty"`
ResponseXMagentoCacheControl string `json:"responseXMagentoCacheControl,omitempty"`
ResponseXDrupalDynamicCache string `json:"responseXDrupalDynamicCache,omitempty"`
ResponseXMagentoTags string `json:"responseXMagentoTags,omitempty"`
ResponseXShopifyStage string `json:"responseXShopifyStage,omitempty"`
ResponseXShopifyRequestID string `json:"responseXShopifyRequestId,omitempty"`
ResponseXWPTotal string `json:"responseXWpTotal,omitempty"`
ResponseXWPTotalPages string `json:"responseXWpTotalPages,omitempty"`
ResponseXCraftCache string `json:"responseXCraftCache,omitempty"`
ResponseXDiscourseRoute string `json:"responseXDiscourseRoute,omitempty"`
ResponseXGhostCacheStatus string `json:"responseXGhostCacheStatus,omitempty"`
ResponseXJoomlaCache string `json:"responseXJoomlaCache,omitempty"`
ResponseXDiscourseMediaType string `json:"responseXDiscourseMediaType,omitempty"`
ResponseXPrestaShopCache string `json:"responseXPrestaShopCache,omitempty"`
ResponseXMagentoCacheDebug string `json:"responseXMagentoCacheDebug,omitempty"`
ResponseXTypo3Cache string `json:"responseXTypo3Cache,omitempty"`
ResponseXWixRequestId string `json:"responseXWixRequestId,omitempty"`
ResponseXSquarespaceRequestId string `json:"responseXSquarespaceRequestId,omitempty"`
ResponseXWebflowRequestId string `json:"responseXWebflowRequestId,omitempty"`
ResponseXContentfulRequestId string `json:"responseXContentfulRequestId,omitempty"`
ResponseXNetlifyRequestId string `json:"responseXNetlifyRequestId,omitempty"`
ResponseXVercelId string `json:"responseXVercelId,omitempty"`
ResponseXHerokuRequestId string `json:"responseXHerokuRequestId,omitempty"`
ResponseXRenderRequestId string `json:"responseXRenderRequestId,omitempty"`
ResponseXRailwayRequestId string `json:"responseXRailwayRequestId,omitempty"`
ResponseXFlyRequestId string `json:"responseXFlyRequestId,omitempty"`
ResponseXDenoRegion string `json:"responseXDenoRegion,omitempty"`
ResponseXCloudflareWorkersRequestId string `json:"responseXCloudflareWorkersRequestId,omitempty"`
ResponseXAzureRef string `json:"responseXAzureRef,omitempty"`
ResponseXGCPRegion string `json:"responseXGcpRegion,omitempty"`
ResponseXAmzCfId string `json:"responseXAmzCfId,omitempty"`
}
type Result ¶
type Result struct {
URL string `json:"url"`
CanonicalURL string `json:"canonicalUrl,omitempty"`
Title string `json:"title"`
Content string `json:"content"`
Byline string `json:"byline"`
PublishedDate string `json:"publishedDate,omitempty"`
Language string `json:"language,omitempty"`
Charset string `json:"charset,omitempty"`
Section string `json:"section,omitempty"`
Description string `json:"description,omitempty"`
ImageURL string `json:"imageUrl,omitempty"`
Excerpt string `json:"excerpt"`
SiteName string `json:"sitename"`
Length int `json:"length"`
TimeMs int64 `json:"timeMs"`
Confidence int `json:"confidence"`
IsSPA bool `json:"isSpa"`
IsBlocked bool `json:"isBlocked"`
SPASignals []string `json:"spaSignals,omitempty"`
Error string `json:"error,omitempty"`
FromCache bool `json:"fromCache,omitempty"`
CacheHit bool `json:"cacheHit,omitempty"`
CacheRevalidated bool `json:"cacheRevalidated,omitempty"`
CacheStale bool `json:"cacheStale,omitempty"`
StatusCode int `json:"statusCode,omitempty"`
HeadOnly bool `json:"headOnly,omitempty"`
Protocol string `json:"protocol,omitempty"`
BlockedByRobots bool `json:"blockedByRobots,omitempty"`
HeadingCount int `json:"headingCount"`
LinkCount int `json:"linkCount"`
ParagraphCount int `json:"paragraphCount"`
Quality float64 `json:"quality"`
QualityInfo QualityMetrics `json:"qualityInfo"`
Profile PageProfile `json:"profile"`
PageClass PageClass `json:"pageClass"`
Fingerprint string `json:"fingerprint"`
Validation Validation `json:"validation"`
TransportInfo
IsSoft404 bool `json:"isSoft404,omitempty"`
Soft404Hints []string `json:"soft404Hints,omitempty"`
ResponseHeaders
NormalizedCacheStatus string `json:"normalizedCacheStatus,omitempty"`
CacheStatusSource string `json:"cacheStatusSource,omitempty"`
CDNInfo
CacheAnalysis
DedupeStats
Links []LinkRef `json:"links,omitempty"`
Images []ImageRef `json:"images,omitempty"`
Tables []TableRef `json:"tables,omitempty"`
Comments []CommentRef `json:"comments,omitempty"`
Chunks []Chunk `json:"chunks,omitempty"`
SplitFiles []SplitFile `json:"splitFiles,omitempty"`
RankedSections []RankedSection `json:"rankedSections,omitempty"`
Schema map[string]interface{} `json:"schema,omitempty"`
Warnings []string `json:"warnings,omitempty"`
Truncated bool `json:"truncated,omitempty"`
PruneFallbackUsed bool `json:"pruneFallbackUsed,omitempty"`
ExtractionMethod string `json:"extractionMethod,omitempty"`
SecurityBlock string `json:"securityBlock,omitempty"`
// contains filtered or unexported fields
}
func FromHTMLWithOptions ¶
func FromResponse ¶
func FromURLContext ¶ added in v0.2.0
func FromURLWithDedupe ¶
func FromURLWithOptions ¶
type RetryEvent ¶
type SampleStrategy ¶ added in v0.2.0
type SampleStrategy string
const ( SampleBalanced SampleStrategy = "balanced" SampleRandom SampleStrategy = "random" SamplePriority SampleStrategy = "priority" )
type Schema ¶
func LoadSchema ¶
type ScrapeOptions ¶ added in v0.2.0
type ScrapeOptions struct {
BaseURL string
MaxPages int
MaxPerPattern int
Full bool
IncludePatterns []string
ExcludePatterns []string
SampleStrategy SampleStrategy
Output OutputFormat
WithPerformance bool
RespectRobots *bool
Timeout time.Duration
UserAgent string
Security *SecurityPolicy
Since time.Time
}
type ScrapeResult ¶ added in v0.2.0
type ScrapeResult struct {
Site SiteInfo `json:"site"`
PageGroups []PageGroup `json:"pageGroups"`
Pages []PageObject `json:"pages"`
Summary ScrapeSummary `json:"summary"`
}
func ScrapeSite ¶ added in v0.2.0
func ScrapeSite(ctx context.Context, opts *ScrapeOptions) (*ScrapeResult, error)
type ScrapeSummary ¶ added in v0.2.0
type SecurityPolicy ¶
type SecurityPolicy struct {
BlockPrivateIPs bool
TrustedResolveCIDRs []string
AllowedDomains []string
DeniedDomains []string
AllowedSchemes []string
MaxRedirects int
RevalidateRedirects bool
MaxResponseBytes int64
MaxDecompressedBytes int64
Resolver IPResolver
URLFilter func(ctx context.Context, rawURL string) error `json:"-"`
}
func DefaultSecurityPolicy ¶
func DefaultSecurityPolicy() *SecurityPolicy
func (*SecurityPolicy) ValidateURL ¶
func (p *SecurityPolicy) ValidateURL(ctx context.Context, rawURL string) error
type SitemapEntry ¶
type SitemapEntry struct {
Loc string `json:"loc"`
LastMod string `json:"lastmod,omitempty"`
ChangeFreq string `json:"changefreq,omitempty"`
Priority string `json:"priority,omitempty"`
}
func FlattenSitemap ¶
func FlattenSitemap(ctx context.Context, sitemapURL string, opts FlattenSitemapOptions) ([]SitemapEntry, error)
type SnapshotNode ¶
type SnapshotNode struct {
Role string `json:"role"`
Name string `json:"name,omitempty"`
Tag string `json:"tag,omitempty"`
Ref string `json:"ref,omitempty"`
Selector string `json:"selector,omitempty"`
Depth int `json:"depth,omitempty"`
Interactive bool `json:"interactive,omitempty"`
Level int `json:"level,omitempty"`
Value string `json:"value,omitempty"`
Href string `json:"href,omitempty"`
Checked *bool `json:"checked,omitempty"`
Disabled bool `json:"disabled,omitempty"`
Children []SnapshotNode `json:"children,omitempty"`
}
func BuildSnapshot ¶
func BuildSnapshot(htmlStr string) (*SnapshotNode, error)
func BuildSnapshotWithOptions ¶
func BuildSnapshotWithOptions(htmlStr string, opts SnapshotOptions) (*SnapshotNode, error)
func (*SnapshotNode) ToCompact ¶
func (n *SnapshotNode) ToCompact() string
type SnapshotOptions ¶
type SplitConfig ¶
type SplitFile ¶
type SplitFile struct {
Path string `json:"path"`
Index int `json:"index"`
Of int `json:"of"`
Bytes int `json:"bytes"`
}
func SplitResultToFiles ¶
func SplitResultToFiles(r Result, cfg SplitConfig) ([]SplitFile, error)
type TableRef ¶
type TableRef struct {
Caption string `json:"caption,omitempty"`
Headers []string `json:"headers,omitempty"`
Rows [][]string `json:"rows"`
}
func ExtractTables ¶
type TextFallbackResult ¶
func TextFallback ¶
func TextFallback(htmlStr string) TextFallbackResult
type TransportInfo ¶ added in v0.2.0
type TransportInfo struct {
RetryCount int `json:"retryCount,omitempty"`
TotalRetryWait time.Duration `json:"totalRetryWait,omitempty"`
HeadPreflightStatus int `json:"headPreflightStatus,omitempty"`
FetchTimeMs int64 `json:"fetchTimeMs,omitempty"`
ParseTimeMs int64 `json:"parseTimeMs,omitempty"`
ConvertTimeMs int64 `json:"convertTimeMs,omitempty"`
ContentLength int64 `json:"contentLength,omitempty"`
ResponseContentType string `json:"responseContentType,omitempty"`
RedirectCount int `json:"redirectCount,omitempty"`
RedirectChain []string `json:"redirectChain,omitempty"`
FinalURL string `json:"finalUrl,omitempty"`
}
type Validation ¶
type Validation struct {
IsValid bool `json:"isValid"`
NeedsBrowser bool `json:"needsBrowser"`
Confidence float64 `json:"confidence"`
Issues []string `json:"issues"`
LinkDensity float64 `json:"linkDensity"`
SkeletonScore float64 `json:"skeletonScore"`
ContentRatio float64 `json:"contentRatio"`
}
func ValidateExtraction ¶
func ValidateExtraction(r *Result) Validation
Source Files
¶
- aria.go
- authwall.go
- binary.go
- bm25.go
- cache.go
- canonical.go
- cdn.go
- charset.go
- chunk.go
- chunk_config.go
- citations.go
- classify.go
- cleanup.go
- comments.go
- dataurl.go
- dedupe.go
- detect.go
- dom.go
- eval_corpus.go
- extract.go
- extract_authors.go
- extract_head_only.go
- extract_markdown.go
- extract_pdf.go
- extract_raw.go
- fallbacks.go
- feed.go
- fetch.go
- fetch_document.go
- fetch_setup.go
- finalize.go
- fingerprint.go
- headers.go
- html_scan.go
- http.go
- images.go
- index_extract.go
- language.go
- ldjson.go
- ldjson_metadata.go
- links.go
- links_retention.go
- llmcontent.go
- markdown_truncate.go
- metadata.go
- options.go
- pdf.go
- preprocess.go
- probe_search.go
- prune.go
- quality.go
- ratelimit.go
- result.go
- robots.go
- sanitize.go
- schema.go
- scrape.go
- scrape_discover.go
- scrape_group.go
- scrape_page.go
- scrape_pool.go
- scrape_render.go
- scrape_sample.go
- scrape_summary.go
- security.go
- selectors.go
- sitemap.go
- snapshot.go
- snapshot_render.go
- soft404.go
- split.go
- tables.go
- text_fallback.go
- trace.go
- useragents.go
- utls.go
- validate.go
- xmlout.go
Click to show internal directories.
Click to hide internal directories.