gheadless

package
v0.0.0-...-bad6181 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2024 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TaskNavigate   = "navigate"
	TaskScreenshot = "screenshot"
	TaskFullHtml   = "full-html"
)

Functions

func ScreenShot

func ScreenShot(urlStr, path string) error

Types

type Chrome

type Chrome struct {
	Resolution       string
	ChromeTimeout    int
	ChromeTimeBudget int
	Path             string
	UserAgent        string
	Argvs            []string

	ScreenshotPath string
}

Chrome contains information about a Google Chrome instance, with methods to run on it.

func New

func New() *Chrome

func (*Chrome) ScreenshotURL

func (chrome *Chrome) ScreenshotURL(targetURL *url.URL, destination string) error

ScreenshotURL takes a screenshot of a URL

func (*Chrome) SetScreenshotPath

func (chrome *Chrome) SetScreenshotPath(p string) error

SetScreenshotPath sets the path for screenshots

func (*Chrome) Setup

func (chrome *Chrome) Setup()

Setup configures a Chrome struct with the path specified to what is available on this system.

type ChromeDP

type ChromeDP struct {
	// contains filtered or unexported fields
}

func NewChromeDP

func NewChromeDP() *ChromeDP

func (*ChromeDP) DoTask

func (ch *ChromeDP) DoTask(urlStr, proxy string, tasks []string, log glog.Interface, timeout time.Duration) (map[string][]byte, error)

func (*ChromeDP) GetFullHtml

func (ch *ChromeDP) GetFullHtml(urlStr, proxy string, log glog.Interface, timeout time.Duration) ([]byte, error)

func (*ChromeDP) Navigate

func (ch *ChromeDP) Navigate(urlStr, proxy string, log glog.Interface, timeout time.Duration) ([]byte, error)

func (*ChromeDP) Screenshot

func (ch *ChromeDP) Screenshot(urlStr, proxy string, log glog.Interface, timeout time.Duration) ([]byte, error)

func (*ChromeDP) SetUserDataDir

func (ch *ChromeDP) SetUserDataDir(dir string)

SetUserDataDir is the command line option to set the user data dir, all the tasks will share the cookies.

Note: set this option to manually set the profile directory used by Chrome. When this is not set, then a default path will be created in the /tmp directory.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL