Documentation ¶
Index ¶
- func ConnectChromeBrowser(leakless, headless bool) (br *rod.Browser, err error)
- func ConnectChromiumBrowser(leakless, headless bool) (br *rod.Browser, err error)
- func ConnectDefaultBrowser(leakless, headless bool) (br *rod.Browser, err error)
- func ConnectEdgeBrowser(leakless, headless bool, ieMode bool) (br *rod.Browser, err error)
- func ElementVisible(page *rod.Page, selector string) bool
- func EmptyDirectory(dir string) error
- func ExecShell(ctx context.Context, command string) (string, error)
- func ExtractUrlParam(urlString, paramName string) (string, error)
- func FileExists(name string) (bool, error)
- func GBK2UTF8(s string) string
- func GetDictAndLastSegmentByPath(data map[string]interface{}, path string) (interface{}, string)
- func MustWaitDownloadRelax(b *rod.Browser) func() ([]byte, string)
- func NormalizeFilename(name string) string
- func OpenPage(browser *rod.Browser, url string, sleep int64, selector string, sign WaitSign) (page *rod.Page, err error)
- func QueryElem(page *rod.Page, selector string) (*rod.Element, error)
- func RaceShow(page *rod.Page, selectors []string, timeoutSeconds int) (index int, elem *rod.Element, err 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)
- type ConfigNode
- type Crawler
- func (c *Crawler) AttachChromeBrowser() error
- func (c *Crawler) AttachDefaultBrowser() error
- func (c *Crawler) AttachEdgeBrowser(ieMode bool) error
- func (c *Crawler) AttachEmbedBrowser() error
- func (c *Crawler) Close()
- 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 DictData
- type DownloadConfig
- type DownloadFileInfo
- type DownloadResult
- type DownloadTypeString
- type ExecuteResult
- type ExternalResult
- type PageLoad
- type Result
- type WaitSign
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectChromeBrowser ¶ added in v1.1.5
ConnectChromeBrowser returns the Chrome browser if installed
func ConnectChromiumBrowser ¶ added in v1.1.6
ConnectChromiumBrowser returns the rod's embed browser
func ConnectDefaultBrowser ¶ added in v1.1.5
ConnectDefaultBrowser returns the system's default browser
func ConnectEdgeBrowser ¶ added in v1.1.6
ConnectEdgeBrowser returns the Edge browser if installed
func ElementVisible ¶
ElementVisible detects whether the selected element is existed and visible
func EmptyDirectory ¶ added in v1.1.3
EmptyDirectory will delete all the contents of a directory
func ExtractUrlParam ¶ added in v1.2.2
func FileExists ¶ added in v1.0.4
FileExists to check if a file exists
func GetDictAndLastSegmentByPath ¶ added in v1.2.0
GetDictAndLastSegmentByPath returns the data extracted from the path and the last segment of the path.
func MustWaitDownloadRelax ¶ added in v1.2.10
func NormalizeFilename ¶ added in v1.0.4
NormalizeFilename will replace <>:"/\|?* in string
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
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) AttachChromeBrowser ¶ added in v1.1.0
func (*Crawler) AttachDefaultBrowser ¶ added in v1.0.1
func (*Crawler) AttachEdgeBrowser ¶ added in v1.1.6
func (*Crawler) AttachEmbedBrowser ¶ added in v1.1.7
type CrawlerConfig ¶ added in v1.0.5
type CrawlerConfig struct { PageLoad PageLoad `json:"pageLoad,omitempty"` DataSection []DictData `json:"dataSection"` SwitchSection DictData `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"` LinkProper string `json:"linkProper,omitempty"` LinkRender string `json:"linkRender,omitempty"` InsertTo string `json:"insertTo,omitempty"` DownloadType DownloadTypeString `json:"downloadType"` }
type DownloadFileInfo ¶ added in v1.2.0
type DownloadResult ¶ added in v1.0.5
type DownloadResult struct { Label string `json:"label"` Files []DownloadFileInfo `json:"files"` }
DownloadResult is a part of result section
type DownloadTypeString ¶ added in v1.2.1
type DownloadTypeString string
const ( DownloadUrl DownloadTypeString = "url" DownloadElement DownloadTypeString = "element" PrintToPDF DownloadTypeString = "toPDF" )
type ExecuteResult ¶ added in v1.2.0
type ExecuteResult struct {
// contains filtered or unexported fields
}
type ExternalResult ¶ added in v1.0.5
type Result ¶ added in v1.0.5
type Result struct { Data DictData `json:"data"` DownloadRoot string `json:"downloadRoot"` Downloads map[string]DownloadResult `json:"downloads"` ExternalSection map[string]ExternalResult `json:"externalSection"` }