Skip to main content

Rejecting Undesired Requests

Rest API (Without Stealth)

You can use rejectResourceTypes and rejectRequestPattern to block undesired content, resources and requests.

Bot detection

Browserless recommends using our REST API to take screenshots, unless you need to get past bot detectors.

curl -X POST \
https://production-sfo.browserless.io/screenshot?token=YOUR_API_TOKEN_HERE \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{
"url": "https://browserless.io/",
"rejectResourceTypes": ["image"],
"rejectRequestPattern": ["/^.*\\.(css)"]
}' \
--output "screenshot.png"

BQL (Stealth)

If the /screenshot API is getting blocked by bot detectors, then we would recommend trying BrowserQL.

mutation Screenshot {
reject(type: [image, stylesheet]) {
enabled
time
}

goto(url: "https://browserless.io/") {
status
}

screenshot(type: webp) {
base64
}
}
BQL Schemas

For more details on BQL mutations, refer to the BrowserQL Schema reference pages.