Documentation
¶
Index ¶
- func ChangeIndexServer(server string)
- func EscapeURL(url string) string
- func ExtensionByContent(content []byte) string
- func FetchURLData(url string, saveto string, config Config)
- func IsExtensionExist(allowedExtensions []string, extension string) bool
- func SaveContent(pages []IndexAPI, saveTo string, timeout int) error
- type Config
- type IndexAPI
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChangeIndexServer ¶
func ChangeIndexServer(server string)
ChangeIndexServer ... changes default address `http://index.commoncrawl.org/`
func EscapeURL ¶
EscapeURL ... Makes possible to create files with URL name by replacing system chars with %<char code>
func ExtensionByContent ¶
ExtensionByContent ... Returns extension of file by detecting its MIME type, `.none` returned if no MIME found
func FetchURLData ¶
FetchURLData ... Fetches pages located on the given URL from Common Crawl archive using Index API and saves them to the pointed location Set `crawlDB` argument empty if not sure what it is
func IsExtensionExist ¶
IsExtensionExist ...Return `true` if there is extension in allowed or false if there is no returns `true` if length of `allowedExtensions` == 0
func SaveContent ¶
SaveContent ... Saves pages or text that were found in Common Crawl to choosen folder
pages: info about found web pages from `getIndex` function saveTo: destination fodler, where save fetched web data timeout: timeout in seconds, default 30
Types ¶
type Config ¶
type Config struct {
ResultChan chan Result
Timeout int
CrawlDB string
WaitMS int
Extensions []string
MaxAmount int
}
Config ... Holds configurations of crawler
type IndexAPI ¶
type IndexAPI struct {
Urlkey string `json:"urlkey,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
Charset string `json:"charset,omitempty"`
Mime string `json:"mime,omitempty"`
Languages string `json:"languages,omitempty"`
MimeDetected string `json:"mimedetected,omitempty"`
Digest string `json:"digest,omitempty"`
Offset string `json:"offset,omitempty"`
URL string `json:"url,omitempty"`
Length string `json:"length,omitempty"`
Status string `json:"status,omitempty"`
Filename string `json:"filename,omitempty"`
}
IndexAPI ... API Response structure from `index.commoncrawl.org`
func GetPagesInfo ¶
GetPagesInfo ... Makes request to commoncrawl index API to gather all offsets that contain pointed URL
crawl: Crawl a database which should be used, e.g 'CC-MAIN-2019-22'; url: URL of a site, offsets and other info of which should be returned. timeout: timeout in seconds, default 30
Returns a list of JSON objects with information about each file offset and other data.