sitecrawl

package
v1.167.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sitecrawl copies an existing site into the files of a release (#2518), so a site moved off a CMS keeps its URLs: every page is filed at the path it answered at, an address that redirected becomes a rule of the release's redirect map, and the sitemap and robots file come along.

Everything fetched is untrusted and everything fetched from is chosen by a caller, so every request goes through the egress guard, every redirect is recorded rather than followed by the client, and a run is bounded by pages and bytes. A form named in the form map is replaced by a frame of the platform form it becomes, built from a checked endpoint name and never from anything on the page.

Index

Constants

This section is empty.

Variables

View Source
var ErrStopped = sitesvc.ErrStopped

ErrStopped is what a copy that was asked to stop returns.

Functions

func SourceOf added in v1.156.0

func SourceOf(start string) string

SourceOf is the address a release records it was copied from: the scheme, host and path, since a query or fragment can hold what should not be kept.

Types

type Crawler

type Crawler struct {
	Client   *http.Client
	MaxPages int
	MaxBytes int64
}

Crawler fetches through the egress guard.

func New

func New(cfg siteconfig.CrawlConfig) (*Crawler, error)

New builds a crawler from the configuration.

func (*Crawler) Crawl

func (c *Crawler) Crawl(ctx context.Context, req Request) (*Result, error)

Crawl walks the site from req.Start, staying on its host.

type Request

type Request struct {
	Start string
	// FormMap names, for a page path, the platform form endpoint that replaces
	// the page's <form> elements.
	FormMap map[string]string
	// PortalURL is the platform's address the frames point at.
	PortalURL string
	// MaxPages and MaxBytes bound this copy, the crawler's own bounds when 0.
	MaxPages int
	MaxBytes int64
	// Progress is told after each address how many pages were copied and how
	// many addresses are known, and returns true to stop; nil copies to the end.
	Progress func(sitesvc.CopyStats) (stop bool)
}

Request is one crawl.

type Result

type Result struct {
	Files     []sitesvc.InputFile
	Pages     int
	Redirects int
	Skipped   []site.Skipped
}

Result is what a crawl found.

Jump to

Keyboard shortcuts

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