2018-09-25 21:49:42 -04:00
|
|
|
package cli
|
2018-09-23 02:05:05 -04:00
|
|
|
|
2018-11-30 19:30:55 -05:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"github.com/MontFerret/ferret/pkg/html"
|
|
|
|
"github.com/MontFerret/ferret/pkg/html/dynamic"
|
|
|
|
"github.com/MontFerret/ferret/pkg/html/static"
|
|
|
|
)
|
|
|
|
|
2018-09-23 02:05:05 -04:00
|
|
|
type Options struct {
|
2018-10-07 22:18:57 -04:00
|
|
|
Cdp string
|
|
|
|
Params map[string]interface{}
|
|
|
|
Proxy string
|
|
|
|
UserAgent string
|
2018-10-11 12:39:03 -04:00
|
|
|
ShowTime bool
|
2018-09-23 02:05:05 -04:00
|
|
|
}
|
2018-11-30 19:30:55 -05:00
|
|
|
|
|
|
|
func (opts Options) WithContext(ctx context.Context) context.Context {
|
|
|
|
ctx = html.WithDynamicDriver(
|
|
|
|
ctx,
|
|
|
|
dynamic.WithCDP(opts.Cdp),
|
|
|
|
dynamic.WithProxy(opts.Proxy),
|
|
|
|
dynamic.WithUserAgent(opts.UserAgent),
|
|
|
|
)
|
|
|
|
|
|
|
|
ctx = html.WithStaticDriver(
|
|
|
|
ctx,
|
|
|
|
static.WithProxy(opts.Proxy),
|
|
|
|
static.WithUserAgent(opts.UserAgent),
|
|
|
|
)
|
|
|
|
|
|
|
|
return ctx
|
|
|
|
}
|