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 ¶
var ErrStopped = sitesvc.ErrStopped
ErrStopped is what a copy that was asked to stop returns.
Functions ¶
Types ¶
type Crawler ¶
Crawler fetches through the egress guard.
func New ¶
func New(cfg siteconfig.CrawlConfig) (*Crawler, error)
New builds a crawler from the configuration.
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.