Documentation
¶
Overview ¶
Package parser provides functions for extracting and filtering links from various sources.
Index ¶
- func ExtractLinksFromFile(filePath string) ([]string, error)
- func ExtractLinksFromURL(targetURL string, ignoreCert bool) ([]string, error)
- func FilterLinksByRegex(links []string, regex string) ([]string, error)
- func PrintLinksAsHTML(links []string)
- func PrintLinksAsJSON(links []string)
- func PrintLinksAsNumbered(links []string)
- func PrintLinksAsText(links []string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractLinksFromFile ¶
ExtractLinksFromFile reads a file and extracts all links from its content. Supports HTML, JSON, and plain text files. The file size is limited to 10MB for safety. Returns a slice of unique links found in the file or an error if reading or parsing fails.
func ExtractLinksFromURL ¶
ExtractLinksFromURL fetches a URL and extracts all links from its content. Supports HTML, JSON, XML content types. The ignoreCert parameter can be used to skip TLS certificate validation. Returns a slice of unique links found in the content or an error if the fetch or parsing fails.
func FilterLinksByRegex ¶
FilterLinksByRegex filters a slice of links using a regular expression pattern. Only links that match the pattern are returned. Returns an error if the regex pattern is invalid.
func PrintLinksAsHTML ¶
func PrintLinksAsHTML(links []string)
PrintLinksAsHTML prints the links as an HTML unordered list to stdout. Each link is wrapped in an anchor tag that links to itself.
func PrintLinksAsJSON ¶
func PrintLinksAsJSON(links []string)
PrintLinksAsJSON prints the links as a JSON array to stdout. If JSON marshaling fails, an error message is printed.
func PrintLinksAsNumbered ¶
func PrintLinksAsNumbered(links []string)
PrintLinksAsNumbered prints the links as a numbered list to stdout. Each link is prefixed with its position number in the list.
func PrintLinksAsText ¶
func PrintLinksAsText(links []string)
PrintLinksAsText prints the links as plain text to stdout. Each link is printed on a new line.
Types ¶
This section is empty.