mirror of
				https://github.com/MontFerret/ferret.git
				synced 2025-10-30 23:37:40 +02:00 
			
		
		
		
	* Renamed DOCUMENT to PAGE * Added PageLoadParams * Added PageLoadParams * Renamed LoadPageParams -> PageLoadParams * Added support for context.Done() (#201) * Bug/#189 operators precedence (#202) * Fixed math operators precedence * Fixed logical operators precedence * Fixed array operator * Added support for parentheses to enforce a different operator evaluation order * Feature/#200 drivers (#209) * Added new interfaces * Renamed dynamic to cdp driver * Renamed drivers * Added ELEMENT_EXISTS function (#210) * Renamed back PAGE to DOCUMENT (#211) * Added Getter and Setter interfaces
		
			
				
	
	
		
			44 lines
		
	
	
		
			750 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			44 lines
		
	
	
		
			750 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package cli
 | |
| 
 | |
| import (
 | |
| 	"context"
 | |
| 	"github.com/MontFerret/ferret/pkg/drivers"
 | |
| 	"github.com/MontFerret/ferret/pkg/drivers/cdp"
 | |
| 	"github.com/MontFerret/ferret/pkg/drivers/http"
 | |
| )
 | |
| 
 | |
| type Options struct {
 | |
| 	Cdp       string
 | |
| 	Params    map[string]interface{}
 | |
| 	Proxy     string
 | |
| 	UserAgent string
 | |
| 	ShowTime  bool
 | |
| }
 | |
| 
 | |
| func (opts Options) WithContext(ctx context.Context) (context.Context, error) {
 | |
| 	var err error
 | |
| 
 | |
| 	ctx = drivers.WithDynamic(
 | |
| 		ctx,
 | |
| 		cdp.NewDriver(
 | |
| 			cdp.WithAddress(opts.Cdp),
 | |
| 			cdp.WithProxy(opts.Proxy),
 | |
| 			cdp.WithUserAgent(opts.UserAgent),
 | |
| 		),
 | |
| 	)
 | |
| 
 | |
| 	if err != nil {
 | |
| 		return ctx, err
 | |
| 	}
 | |
| 
 | |
| 	ctx = drivers.WithStatic(
 | |
| 		ctx,
 | |
| 		http.NewDriver(
 | |
| 			http.WithProxy(opts.Proxy),
 | |
| 			http.WithUserAgent(opts.UserAgent),
 | |
| 		),
 | |
| 	)
 | |
| 
 | |
| 	return ctx, err
 | |
| }
 |