Documentation
¶
Overview ¶
Package page helps fetching a HTML page and its referenced CSS files.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultMaxPageSize int64 = 1024 * 1024 * 10 DefaultMaxFileCount int = 15 DefaultMaxFileSize int64 = 1024 * 1024 * 5 )
Default limits for fetching a Page.
View Source
var ( MaxPageSize = DefaultMaxPageSize MaxFileCount = DefaultMaxFileCount MaxFileSize = DefaultMaxFileSize )
Limits for fetching a Page.
Functions ¶
This section is empty.
Types ¶
type LimitedReader ¶
LimitedReader reads at most N bytes and returns an error when more than N bytes could have been read.
func NewLimitedReader ¶
func NewLimitedReader(rc io.Reader, l int64) *LimitedReader
NewLimitedReadCloser wraps a Reader and limits the amount of bytes it can read before returning an error.
type Page ¶
Page contains HTML and linked CSS files for a specific URL.
func New ¶
New Page from a URL. Any linked CSS stylesheets will be downloaded.
Example ¶
s := serve() defer s.Close() p, _ := New(context.Background(), s.URL+"/external.html") fmt.Printf("%s: %s\n", p.HTML.URL.Path, p.HTML.Body) fmt.Printf("%s: %s\n", p.CSS[0].URL.Path, p.CSS[0].Body)
Output: /external.html: <link rel="stylesheet" href="style.css"> /style.css: body { color: #c0c0c0 }
Click to show internal directories.
Click to hide internal directories.