jseval

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package jseval provides headless browser page rendering via chromedp. It navigates to a URL using a real Chrome/Chromium instance, waits for JavaScript to execute, and returns the fully rendered HTML DOM.

This complements the colly-based crawler package, which handles HTTP-only crawling. Use jseval for sites that require JavaScript execution (SPAs, Cloudflare challenges, etc.).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Timeout is the maximum time to wait for the page to render.
	// Default: 30 seconds.
	Timeout time.Duration

	// WaitSelector is an optional CSS selector to wait for before extracting HTML.
	// If empty, the renderer waits for Timeout or document idle, whichever comes first.
	WaitSelector string

	// ProxyURL is an optional HTTP/SOCKS proxy for the browser to use.
	ProxyURL string

	// UserAgent overrides the browser's default User-Agent string.
	UserAgent string

	// IgnoreCertErrors makes the browser accept invalid/self-signed certificates.
	// Required for some residential proxies (e.g. Bright Data) that do TLS interception.
	IgnoreCertErrors bool
}

Config controls the headless browser behaviour.

type Result

type Result struct {
	// HTML is the fully rendered outer HTML of the page after JS execution.
	HTML string

	// Title is the document title after rendering.
	Title string

	// FinalURL is the URL after any redirects.
	FinalURL string
}

Result holds the rendered page content.

func RenderPage

func RenderPage(ctx context.Context, targetURL string, config Config) (*Result, error)

RenderPage navigates to the given URL in a headless Chrome instance, waits for JavaScript to execute, and returns the rendered HTML.

func RenderPages

func RenderPages(ctx context.Context, targetURLs []string, config Config) ([]*Result, []error)

RenderPages renders multiple URLs concurrently, each in its own browser tab. Returns results in the same order as the input URLs. Errors are per-URL.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL