Documentation
¶
Index ¶
- func ElementVisible(page *rod.Page, selector string) bool
- func FileExists(name string) (bool, error)
- func NormalizeFilename(name string) string
- func OpenPage(browser *rod.Browser, url string, sleep int64, selector string, sign WaitSign) (page *rod.Page, err error)
- func RemoveContents(dir string) error
- func RenameFileUnique(dir, fileName, ext string, try int) string
- func WaitElementHide(page *rod.Page, selector string, timeoutSeconds int) (err error)
- func WaitElementShow(page *rod.Page, selector string, timeoutSeconds int) (err error)
- func WaitPage(page *rod.Page, sleep int64, selector string, sign WaitSign) (err error)
- func WriteSortedJSONToFile(data interface{}, filename string) error
- type ConfigNode
- type Crawler
- func (c *Crawler) AttachDefaultBrowser() *rod.Browser
- func (c *Crawler) AttachEdgedIE() *rod.Browser
- func (c *Crawler) CrawlPage(page *rod.Page, cfgOrFile interface{}, autoDownload bool, closeTab bool) (*Result, error)
- func (c *Crawler) CrawlUrl(url string, cfgOrFile interface{}, autoDownload bool, closeTab bool) (*Result, *rod.Page, error)
- type CrawlerConfig
- type DownloadConfig
- type DownloadResult
- type DownloadType
- type ExternalResult
- type PageLoad
- type Result
- type WaitSign
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ElementVisible ¶
ElementVisible detects whether the selected element is existed and visible
func FileExists ¶ added in v1.0.4
FileExists to check if a file exists
func NormalizeFilename ¶ added in v1.0.4
NormalizeFilename will replace <>:"/\|?* in string
func RemoveContents ¶ added in v1.0.4
RemoveContents will delete all the contents of a directory
func RenameFileUnique ¶ added in v1.0.4
RenameFileUnique rename file name if there are duplicate files
func WaitElementHide ¶
WaitElementHide waiting for a certain element on the page to disappear
func WaitElementShow ¶
WaitElementShow waiting for a certain element on the page to appear
func WriteSortedJSONToFile ¶ added in v1.0.2
WriteSortedJSONToFile writing indented and key sorted JSON to a file
Types ¶
type ConfigNode ¶ added in v1.0.5
type Crawler ¶ added in v1.0.1
type Crawler struct { Browser *rod.Browser CfgFetcher func(path string) (*CrawlerConfig, error) }
func (*Crawler) AttachDefaultBrowser ¶ added in v1.0.1
func (*Crawler) AttachEdgedIE ¶ added in v1.0.6
type CrawlerConfig ¶ added in v1.0.5
type CrawlerConfig struct { PageLoad PageLoad `json:"pageLoad,omitempty"` DataSection []map[string]interface{} `json:"dataSection"` SwitchSection map[string]interface{} `json:"switchSection,omitempty"` DownloadRoot string `json:"downloadRoot,omitempty"` DownloadSection []DownloadConfig `json:"downloadSection,omitempty"` }
type DownloadConfig ¶ added in v1.0.5
type DownloadConfig struct { ConfigNode SavePath string `json:"savePath,omitempty"` NameProper string `json:"nameProper,omitempty"` NameRender string `json:"nameRender,omitempty"` Type DownloadType `json:"type"` }
type DownloadResult ¶ added in v1.0.5
type DownloadResult struct { Count int `json:"count"` Errors []int `json:"errors"` FileNames []string `json:"fileNames"` Links []string `json:"links"` }
DownloadResult is a part of result section
type DownloadType ¶
type DownloadType string
const ( DownloadUrl DownloadType = "url" DownloadElement DownloadType = "element" )
type ExternalResult ¶ added in v1.0.5
type Result ¶ added in v1.0.5
type Result struct { Data map[string]interface{} `json:"data"` DownloadRoot string `json:"downloadRoot"` Downloads map[string]DownloadResult `json:"downloads"` ExternalSection map[string]ExternalResult `json:"externalSection"` }
Click to show internal directories.
Click to hide internal directories.