Setting Up the Scraper API
ZenRows®’ Scraper API enables fast, efficient, and hassle-free data extraction from web pages by providing versatile scraping modes. Whether you’re new to scraping or already experienced, ZenRows adapts to your needs, making it easy to collect data from the web while overcoming the common challenges posed by modern websites, including CAPTCHAs and anti-bot mechanisms.
Getting started
ZenRows’ API offers a straightforward approach to web scraping with just two key components:
- API key – Your unique key to authenticate requests.
- The encoded URL – The target URL you want to scrape, properly encoded.
Once logged in, you’ll be directed to the Request Builder page, where you can locate your API key and start running your requests.
Here’s what you can do:
- Paste your target URL to configure a request.
- Enable ZenRows parameters like blocking unnecessary resources or specifying JavaScript instructions.
- Select a programming language (e.g., Python) and a connection mode. For general use, select “cURL” to generate the full API endpoint that works with any HTTP client.
- Test the request by clicking “Try It” to execute the request in the browser.
- Copy the generated code and integrate it into your Python script.
Connection modes
ZenRows Scraper API accommodates different needs through three flexible connection methods:
- API Mode: Ideal for quick and easy scraping with all the processing handled by ZenRows. Just pass your API key and URL, and get the data back.
- Proxy Mode: For users who want to maintain control over their scraping logic but need ZenRows’ powerful proxy network, this mode allows you to use ZenRows as a proxy. You can integrate it into your existing system, enabling access to residential, datacenter, and rotating proxies to avoid IP bans and anti-bot systems.
- SDK: ZenRows offers dedicated SDKs for Python and Node.js to simplify integration for developers. These SDKs abstract many low-level details, like request handling, retries, and response processing, making it easy for both beginners and experienced developers to get started quickly.
Response Headers
ZenRows simplifies scraping responses by adding custom headers to the returned data. Headers, including cookies, from the target website are prefixed with Zr-
for easy identification.
Additionally, ZenRows will append a Zr-Final-Url
header showing the final visited URL after any potential redirects, ensuring you always know the last page accessed.
Here’s an example of the headers returned by ZenRows:
Zr-Final-Url
represents the final URL after all redirects, some anti-bot services, such as Cloudflare, may redirect you after a successful request and add parameters to the URL.API Key
Your API Key is the gateway to the ZenRows Scraper API, functioning as both an authentication tool and an identifier for all your requests. Without it, you won’t be able to access ZenRows’ features or receive any scraped data.
You can easily create your API Key by signing up for an account.
URL
The URL you want to scrape must be URL-encoded to prevent issues with special characters like spaces, question marks, and ampersands. Encoding ensures that servers interpret the URL correctly, avoiding common issues like broken requests or misinterpretation of the data.
Always double-check your URLs for proper encoding. If you’re using ZenRows SDKs or common HTTP libraries like requests
in Python or axios
in Node.js, they often handle this for you.
Was this page helpful?