2018-09-26 03:49:42 +02:00
|
|
|
package cli
|
2018-09-23 08:05:05 +02:00
|
|
|
|
2018-12-01 02:30:55 +02: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 08:05:05 +02:00
|
|
|
type Options struct {
|
2018-10-08 04:18:57 +02:00
|
|
|
Cdp string
|
|
|
|
Params map[string]interface{}
|
|
|
|
Proxy string
|
|
|
|
UserAgent string
|
2018-10-11 18:39:03 +02:00
|
|
|
ShowTime bool
|
2018-09-23 08:05:05 +02:00
|
|
|
}
|
2018-12-01 02:30:55 +02: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
|
|
|
|
}
|