chrome

package
v0.0.0-...-6c3eebf Latest Latest
Warning

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

Go to latest
Published: May 26, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPageSource

func GetPageSource(site web.Site) (string, error)

GetPageSource retrieves the source code of the web page currently loaded in the site session. It returns the page source code as a string or an error if the function fails to obtain the source code.

Args:

site (web.Site): a web.Site instance containing the session information for the website to retrieve the source code from.

Returns:

(string): the source code of the web page loaded in the site session.

(error): an error if the function fails to retrieve the source code or if the driver is not of the correct type.

func Init

func Init(headless bool, ignoreCertErrors bool) (web.Browser, error)

Init returns a chrome browser instance.

func Navigate(site web.Site, actions []InputAction, waitTime time.Duration) error

Navigate navigates an input site using the provided InputActions.

func ScreenShot

func ScreenShot(site web.Site, imgPath string) error

ScreenShot takes a screenshot of the input `targetURL` and saves it to `imgPath`.

Types

type Driver

type Driver struct {
	Context context.Context
	Options *[]chromedp.ExecAllocatorOption
}

Driver is used to interface with Google Chrome using go.

func (*Driver) GetContext

func (d *Driver) GetContext() context.Context

GetContext returns the context associated with the Driver.

func (*Driver) SetContext

func (d *Driver) SetContext(ctx context.Context)

SetContext sets the context associated with the Driver.

type InputAction

type InputAction struct {
	Description string
	Selector    string
	Action      chromedp.Action
}

InputAction contains selectors and actions to run with chrome.

Jump to

Keyboard shortcuts

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