mirror of
https://github.com/MontFerret/ferret.git
synced 2024-12-14 11:23:02 +02:00
39e379f0f2
* Decoupled runtime and HTML driver initialization * Updates
34 lines
646 B
Go
34 lines
646 B
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
"github.com/MontFerret/ferret/pkg/html"
|
|
"github.com/MontFerret/ferret/pkg/html/dynamic"
|
|
"github.com/MontFerret/ferret/pkg/html/static"
|
|
)
|
|
|
|
type Options struct {
|
|
Cdp string
|
|
Params map[string]interface{}
|
|
Proxy string
|
|
UserAgent string
|
|
ShowTime bool
|
|
}
|
|
|
|
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
|
|
}
|