Documentation
¶
Index ¶
- Variables
- func AddAtImportLinksToItemChild(item *models.Item, atImportLinks []*models.URL)
- func ExtractFromStringCSS(css string, inline bool) (links []string, atImportLinks []string)
- func ExtractFromURLCSS(URL *models.URL) (links []*models.URL, atImportLinks []*models.URL, err error)
- func GetEmbeddedCSSJump(item *models.Item) int
- func GetURLsFromJSON(decoder *json.Decoder) (assets, outlinks []string, err error)
- func HTMLAssets(item *models.Item) (assets []*models.URL, err error)
- func IsCSS(URL *models.URL) bool
- func IsEmbeddedCSS(item *models.Item) bool
- func IsHTML(URL *models.URL) bool
- func IsJSON(URL *models.URL) bool
- func IsM3U8(URL *models.URL) bool
- func IsSitemapXML(URL *models.URL) bool
- func IsXML(URL *models.URL) bool
- func JSON(URL *models.URL) (assets, outlinks []*models.URL, err error)
- func M3U8(URL *models.URL) (assets []*models.URL, err error)
- func MustStrictHTTPOnly() *regexp.Regexp
- func QuotedLinkRegexFindAll(s string) []string
- func TransformDocument(u *models.URL) (doc *goquery.Document, err error)
- func XML(URL *models.URL) (assets, outlinks []*models.URL, err error)
- type AzureBlob
- type AzureBlobEnumerationResults
- type CommonPrefix
- type HTMLOutlinkExtractor
- type LinkHeaderExtractor
- type Mode
- type ObjectStorageOutlinkExtractor
- type PDFOutlinkExtractor
- type S3ListBucketResult
- type S3Object
- type SitemapXMLOutlinkExtractor
Constants ¶
This section is empty.
Variables ¶
var ( LinkRegexStrict = MustStrictHTTPOnly() LinkRegex = regexp.MustCompile(`(?i)https?://[^<>'",\s/]+\.[^<>'",\s/]+(?:/[^<>'",\s]*)?`) // Adapted from heritrix3's UriUtils (Apache License 2.0) AssetsRegex = `(?i)\b(?:src|href)=["']([^"']+\.(?:css|js|png|jpg|jpeg|gif|svg|webp|woff|woff2|ttf|eot))["']` )
var ObjectStorageServers = func() (s []string) { s = append(s, s3CompatibleServers...) s = append(s, azureServers...) return s }()
All the supported object storage servers
Functions ¶
func AddAtImportLinksToItemChild ¶
Add the @import links to the item as children items if the @import jump is less than the config.MaxCSSJump.
func ExtractFromStringCSS ¶
func ExtractFromURLCSS ¶
func ExtractFromURLCSS(URL *models.URL) (links []*models.URL, atImportLinks []*models.URL, err error)
ExtractFromURLCSS extracts URLs from a CSS URL
func GetEmbeddedCSSJump ¶
Returns the number of @import jumps to reach the HTML item.
for example:
CSS -> HTML: 0 @import jump CSS -> CSS -> HTML: 1 @import jump CSS -> CSS -> CSS -> HTML: 2 @import jump CSS -> ItemGotRedirected -> CSS -> CSS -> HTML: still 2 @import jump (ignores the redirection items)
func GetURLsFromJSON ¶
func IsCSS ¶
https://html.spec.whatwg.org/multipage/links.html#link-type-stylesheet:process-the-linked-resource According to the spec, we should only check the Content-Type header if the resource is came from a HTTP(S) request.
func IsEmbeddedCSS ¶
IsEmbeddedCSS checks if the item is an embedded CSS. An embedded CSS is a CSS item that is linked from an HTML item.
func IsSitemapXML ¶
func MustStrictHTTPOnly ¶
func QuotedLinkRegexFindAll ¶
Helper function to call FindAllStringSubmatch on quotedLinkRegex and return only the capturing group (Quoted URL).
func TransformDocument ¶
TransformDocument transforms the document of a URL by detecting its encoding and creating a utf-8 goquery document.
Types ¶
type AzureBlobEnumerationResults ¶
type AzureBlobEnumerationResults struct {
XMLName xml.Name `xml:"EnumerationResults"`
Prefix string `xml:"Prefix"`
Marker string `xml:"Marker"`
Blobs []AzureBlob `xml:"Blobs>Blob"`
NextMarker string `xml:"NextMarker"`
}
AzureBlobEnumerationResults represents the XML structure of an Azure Blob Storage listing <https://learn.microsoft.com/en-us/rest/api/storageservices/enumerating-blob-resources>
type CommonPrefix ¶
type CommonPrefix struct {
Prefix []string `xml:"Prefix"`
}
type HTMLOutlinkExtractor ¶
type HTMLOutlinkExtractor struct{}
func (HTMLOutlinkExtractor) Support ¶
func (HTMLOutlinkExtractor) Support(m Mode) bool
type LinkHeaderExtractor ¶
type LinkHeaderExtractor struct{}
func (LinkHeaderExtractor) ExtractLink ¶
func (l LinkHeaderExtractor) ExtractLink(URL *models.URL) (URLs []*models.URL)
ExtractLink parses a raw Link header in the form:
<url1>; rel="what", <url2>; rel="any"; another="yes", <url3>; rel="thing"
returning a slice of models.URL structs Each of these are separated by a `, ` and the in turn by a `; `, with the first always being the url, and the remaining the key-val pairs See: https://simon-frey.com/blog/link-header/, https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Link
func (LinkHeaderExtractor) Support ¶
func (l LinkHeaderExtractor) Support(m Mode) bool
type ObjectStorageOutlinkExtractor ¶
type ObjectStorageOutlinkExtractor struct{}
func (ObjectStorageOutlinkExtractor) Extract ¶
ObjectStorage decides which helper to call based on the object storage server
func (ObjectStorageOutlinkExtractor) Match ¶
func (ObjectStorageOutlinkExtractor) Match(URL *models.URL) bool
Check if the response is from an object storage server
func (ObjectStorageOutlinkExtractor) Support ¶
func (ObjectStorageOutlinkExtractor) Support(m Mode) bool
type PDFOutlinkExtractor ¶
type PDFOutlinkExtractor struct{}
func (PDFOutlinkExtractor) Support ¶
func (PDFOutlinkExtractor) Support(m Mode) bool
type S3ListBucketResult ¶
type S3ListBucketResult struct {
XMLName xml.Name `xml:"ListBucketResult"`
Name string `xml:"Name"`
Prefix string `xml:"Prefix"`
Marker string `xml:"Marker"`
Contents []S3Object `xml:"Contents"`
CommonPrefixes []CommonPrefix `xml:"CommonPrefixes"`
IsTruncated bool `xml:"IsTruncated"`
NextContinuationToken string `xml:"NextContinuationToken"`
}
S3ListBucketResult represents the XML structure of an S3 bucket listing
type SitemapXMLOutlinkExtractor ¶
type SitemapXMLOutlinkExtractor struct{}
func (SitemapXMLOutlinkExtractor) Match ¶
func (SitemapXMLOutlinkExtractor) Match(URL *models.URL) bool
func (SitemapXMLOutlinkExtractor) Support ¶
func (SitemapXMLOutlinkExtractor) Support(m Mode) bool