Documentation ¶
Index ¶
- Constants
- func GetWebSocketDebuggerURL(ctx context.Context, u string) (string, error)
- type Browser
- type Launcher
- func (l *Launcher) Bin(path string) *Launcher
- func (l *Launcher) Client() *cdp.Client
- func (l *Launcher) Context(ctx context.Context) *Launcher
- func (l *Launcher) Delete(name string) *Launcher
- func (l *Launcher) Devtools(autoOpenForTabs bool) *Launcher
- func (l *Launcher) FormatArgs() []string
- func (l *Launcher) Get(name string) (string, bool)
- func (l *Launcher) GetFlags(name string) ([]string, bool)
- func (l *Launcher) Headless(enable bool) *Launcher
- func (l *Launcher) JSON() []byte
- func (l *Launcher) KeepUserDataDir() *Launcher
- func (l *Launcher) Launch() string
- func (l *Launcher) LaunchE() (string, error)
- func (l *Launcher) Log(log func(string)) *Launcher
- func (l *Launcher) PID() int
- func (l *Launcher) Reap(enable bool) *Launcher
- func (l *Launcher) RemoteDebuggingPort(port int) *Launcher
- func (l *Launcher) Set(name string, values ...string) *Launcher
- func (l *Launcher) UserDataDir(dir string) *Launcher
- type Proxy
Constants ¶
const DefaultRevision = 768783
DefaultRevision for chrome curl -s -S https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Mac%2FLAST_CHANGE\?alt\=media
const HeaderName = "Rod-Launcher"
HeaderName for remote launch
const HostGoogle = "https://storage.googleapis.com"
HostGoogle to download browser
const HostTaobao = "https://npm.taobao.org/mirrors"
HostTaobao to download browser
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Browser ¶
type Browser struct { Context context.Context // Hosts to download browser, examples: // https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/748030/chrome-linux.zip // https://storage.googleapis.com/chromium-browser-snapshots/Mac/748030/chrome-mac.zip // https://storage.googleapis.com/chromium-browser-snapshots/Win/748030/chrome-win.zip Hosts []string // Revision of the browser to use Revision int // Dir default is the filepath.Join(os.TempDir(), "rod") Dir string // Log to print output Log func(string) }
Browser is a helper to download browser smartly
type Launcher ¶
type Launcher struct { Flags map[string][]string `json:"flags"` // contains filtered or unexported fields }
Launcher is a helper to launch browser binary smartly
func New ¶
func New() *Launcher
New returns the default arguments to start browser. "--" is optional, with or without it won't affect the result. List of switches: https://peter.sh/experiments/chromium-command-line-switches/
func NewUserMode ¶
func NewUserMode() *Launcher
NewUserMode is a preset to enable reusing current user data. Useful for automation of personal browser. If you see any error, it may because you can't launch debug port for existing browser, the solution is to completely close the running browser. Unfortunately, there's no API for rod to tell it automatically yet.
func (*Launcher) FormatArgs ¶
FormatArgs returns the formated arg list for cli
func (*Launcher) KeepUserDataDir ¶
KeepUserDataDir after remote browser is closed. By default user-data-dir will be removed.
func (*Launcher) Launch ¶
Launch a standalone temp browser instance and returns the debug url. bin and profileDir are optional, set them to empty to use the default values. If you want to reuse sessions, such as cookies, set the userDataDir to the same location.
func (*Launcher) RemoteDebuggingPort ¶
RemoteDebuggingPort arg
func (*Launcher) UserDataDir ¶
UserDataDir is where the browser will look for all of its state, such as cookie and cache. When set to empty, system user's default dir will be used.
type Proxy ¶
type Proxy struct {
Log func(string)
}
Proxy to help launch browser remotely. Any http request will return a default Launcher based on remote OS environment. Any websocket request will start a new browser and the request will be proxied to the browser. The websocket header "Rod-Launcher" holds the options to launch browser. If the websocket is closed, the browser will be killed.