Accept
, Cookie
, or Referer
. These can be useful for:
- Controlling the expected content type (e.g., application/json)
- Maintaining session continuity with cookies
- Mimicking user behavior through referrer URLs
https://www.google.com
can help simulate a user arriving from a Google search, which some websites use as a trust signal to serve less restricted or personalized content.
ZenRows Header Management
ZenRows automatically manages certain browser-related headers to ensure consistency, high success rates, and protection against anti-bot systems. These include headers such as:User-Agent
Accept-Encoding
Sec-Ch-Ua
(Client Hints)Sec-Fetch-Mode
Sec-Fetch-Site
Sec-Fetch-User
Enabling Custom Headers
To include your own headers, set thecustom_headers
parameter to true in your API request. This enables your custom headers while ZenRows continues to manage sensitive browser-specific ones.
Example Use Case: Using Referer
Some websites change their content based on the Referer
header. For instance, if you’re scraping a product page and want it to appear as if a user clicked on a Google search result, you might set:
Frequently Asked Questions (FAQ)
What are custom headers, and why would I use them?
What are custom headers, and why would I use them?
Custom headers allow you to modify the HTTP headers in your requests, such as
Referer
, Accept
, or Cookie
, to control how the request is perceived by the target server. This can be useful for handling sessions, mimicking specific browser behaviors, or requesting specific content types.Which headers are automatically managed by ZenRows®?
Which headers are automatically managed by ZenRows®?
ZenRows manages certain headers related to browser environment and request consistency, such as
User-Agent
, Accept-Encoding
, Sec-Fetch-*
, and Client-Hints
. This helps ensure success and reliability when scraping protected or complex websites.Why are some headers forbidden?
Why are some headers forbidden?
Headers such as
Sec-Ch-Ua
and Accept-Encoding
are tightly coupled with browser behavior and could trigger anti-scraping mechanisms if set improperly. ZenRows prevents manual customization of these headers to ensure optimal success rates and avoid unnecessary blocks.What happens if I set a forbidden header?
What happens if I set a forbidden header?
If you attempt to set a forbidden header, it will be ignored by ZenRows, and the request will proceed with the default browser headers managed by the system. This prevents potential issues that could arise from incorrect configurations.
Can I override the browser-based headers handled by ZenRows®?
Can I override the browser-based headers handled by ZenRows®?
No, you cannot manually set or override headers like
Sec-Ch-Ua
, Accept-Encoding
, and Sec-Fetch-*
. These are managed by ZenRows to optimize performance and prevent blocks during web scraping.