Skip to content

Commit

Permalink
minor: Adds supports AI Anti-bot solution
Browse files Browse the repository at this point in the history
  • Loading branch information
renatoaraujo committed Oct 10, 2023
1 parent 7d0baca commit 06effe0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,15 @@ func WithSessionID(sessionID int) ScrapeOptions {
}
}

// WithAIAntiBot sets the anti-bot
// Some websites protect their content with anti-bot solutions such as Cloudfare, Akamai, or Datadome. Enable Anti-bot to bypass them easily without any hassle.
func WithAIAntiBot() ScrapeOptions {
return func(values url.Values) {
values.Set("js_render", "true")
values.Set("antibot", "true")
}
}

// ApplyParameters applies the chosen scraping options to a URL.
// It modifies the URL's query string based on the provided scraping options.
//
Expand Down
5 changes: 5 additions & 0 deletions api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ func TestScrapeOptions(t *testing.T) {
zenrows.WithSessionID(12345),
url.Values{"session_id": []string{"12345"}},
},
{
"WithAIAntiBot",
zenrows.WithAIAntiBot(),
url.Values{"js_render": []string{"true"}, "antibot": []string{"true"}},
},
}

for _, tt := range tests {
Expand Down

0 comments on commit 06effe0

Please sign in to comment.