mirror of
https://github.com/MontFerret/ferret.git
synced 2024-12-16 11:37:36 +02:00
71c246dd17
* Added KeepCookies option to CDP driver * Added LoadDocumentParams * Added COOKIE_GET and COOKIE_SET methods
60 lines
937 B
Go
60 lines
937 B
Go
package cdp
|
|
|
|
type (
|
|
Options struct {
|
|
Name string
|
|
Proxy string
|
|
UserAgent string
|
|
Address string
|
|
KeepCookies bool
|
|
}
|
|
|
|
Option func(opts *Options)
|
|
)
|
|
|
|
const DefaultAddress = "http://127.0.0.1:9222"
|
|
|
|
func newOptions(setters []Option) *Options {
|
|
opts := new(Options)
|
|
opts.Name = DriverName
|
|
opts.Address = DefaultAddress
|
|
|
|
for _, setter := range setters {
|
|
setter(opts)
|
|
}
|
|
|
|
return opts
|
|
}
|
|
|
|
func WithAddress(address string) Option {
|
|
return func(opts *Options) {
|
|
if address != "" {
|
|
opts.Address = address
|
|
}
|
|
}
|
|
}
|
|
|
|
func WithProxy(address string) Option {
|
|
return func(opts *Options) {
|
|
opts.Proxy = address
|
|
}
|
|
}
|
|
|
|
func WithUserAgent(value string) Option {
|
|
return func(opts *Options) {
|
|
opts.UserAgent = value
|
|
}
|
|
}
|
|
|
|
func WithKeepCookies() Option {
|
|
return func(opts *Options) {
|
|
opts.KeepCookies = true
|
|
}
|
|
}
|
|
|
|
func WithCustomName(name string) Option {
|
|
return func(opts *Options) {
|
|
opts.Name = name
|
|
}
|
|
}
|