mirror of
https://github.com/MontFerret/ferret.git
synced 2024-12-16 11:37:36 +02:00
29 lines
524 B
Go
29 lines
524 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"os"
|
|
|
|
"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)
|
|
}
|