Skip to content

Commit

Permalink
feat: allow sending custom params to use newly released or experiment…
Browse files Browse the repository at this point in the history
…al features
  • Loading branch information
rdelcampog committed Oct 29, 2024
1 parent d06a75f commit 16b4106
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions service/api/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ type RequestParameters struct {
// automatically for each request. If you provide custom headers, the scraping quality may be affected. Use this feature only if you
// know what you are doing.
CustomHeaders http.Header `json:"custom_headers,omitempty" structs:"-" schema:"-"`

// CustomParams is a map of custom parameters that will be passed to the ZenRows Scraper API. These parameters will be passed as query
// parameters in the request, and can be used to pass new features or options that are not available in the standard parameters.
CustomParams map[string]string `json:"custom_params,omitempty" structs:"-" schema:"-"`
}

func (p *RequestParameters) Validate() error { //nolint:gocyclo
Expand Down Expand Up @@ -316,6 +320,10 @@ func (p *RequestParameters) ToURLValues() url.Values {
}
}

for k, v := range p.CustomParams {
values.Set(k, v)
}

// if custom headers are set, we need to set the custom_headers flag to true
if len(p.CustomHeaders) > 0 {
values.Set("custom_headers", "true")
Expand Down

0 comments on commit 16b4106

Please sign in to comment.