1
0
mirror of https://github.com/MontFerret/ferret.git synced 2024-12-16 11:37:36 +02:00
ferret/examples/cookies.go
3timeslazy acf2f13dcb Linter Cleanups (#294)
* sync with MontFerret/ferret

* fix --param handling

When params is converted to map it uses strings.Split,
which slices a string into all substrings separated by :.

* remove impossible conditions nil != nil

* delete ineffectual assignments

* replace '+= 1' with '++'

* remove useless comparison with nil

* merge variable declarations

* remove bool comparison

* fix imports

* fix imports

* delete unused file

* use copy instead of loop

* delete unused DummyInterface

* remove unnecassary break statements

* tidy modules
2019-05-03 17:10:34 -04:00

27 lines
511 B
Go

package main
import (
"context"
"github.com/MontFerret/ferret/pkg/compiler"
"github.com/MontFerret/ferret/pkg/drivers"
"github.com/MontFerret/ferret/pkg/drivers/cdp"
)
func run(q string) ([]byte, error) {
comp := compiler.New()
program := comp.MustCompile(q)
// create a root context
ctx := context.Background()
// we inform the driver to keep cookies between queries
ctx = drivers.WithContext(
ctx,
cdp.NewDriver(cdp.WithKeepCookies()),
drivers.AsDefault(),
)
return program.Run(ctx)
}