transport

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package transport provides a shared network layer for fetching web content. It supports two levels: direct HTTP and browser-based (CDP).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// WSURL is the remote CDP WebSocket URL. If empty, a local Chrome is launched.
	WSURL string
	// ProfileDir is the Chrome user data directory for persistent cookies/storage.
	ProfileDir string
	// Headless controls whether Chrome runs in headless mode (default: true).
	Headless bool
}

Config holds transport configuration.

type Transport

type Transport struct {
	// contains filtered or unexported fields
}

Transport provides shared HTTP and browser-based network access.

func New

func New(config Config) *Transport

New creates a new Transport with the given config.

func (*Transport) BrowseEval

func (t *Transport) BrowseEval(ctx context.Context, url string, js string) (any, error)

BrowseEval navigates to a URL in a browser and evaluates JavaScript.

func (*Transport) BrowseHTML

func (t *Transport) BrowseHTML(ctx context.Context, url string) (string, error)

BrowseHTML navigates to a URL in a browser and returns the rendered HTML.

func (*Transport) Close

func (t *Transport) Close() error

Close releases resources held by the transport.

func (*Transport) Do

func (t *Transport) Do(ctx context.Context, req *http.Request) (*http.Response, error)

Do executes an HTTP request and returns the response. Caller is responsible for closing the response body.

func (*Transport) GetHTML

func (t *Transport) GetHTML(ctx context.Context, url string) (string, error)

GetHTML fetches a URL via direct HTTP and returns the response body as a string.

Jump to

Keyboard shortcuts

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