ZenRows is a Python client for the ZenRows API, designed to simplify web scraping by automatically handling challenges like proxy rotation, CAPTCHA solving, and JavaScript rendering. It enables users to extract data from complex, anti-bot protected websites. The library is actively maintained, currently at version 1.4.0, with regular updates to its API and SDKs.
pip install zenrowsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the ZenRows client with an API key (preferably from an environment variable) and make a basic GET request to a target URL, enabling common features like JavaScript rendering and premium proxies. The response object is a standard `requests.Response` object.
Initialize client with `client = ZenRowsClient('YOUR-API-KEY', retries=3)`.Wrap async calls in an `async def main():` and execute with `asyncio.run(main())`.
Be cautious with custom headers; only send them if necessary and test thoroughly. Contact ZenRows support if issues arise.
Pass a dictionary of CSS selectors to the `css_extractor` parameter: `params={'css_extractor': {'title': 'h1', 'links': 'a @href'}}`.Always store your API key securely, preferably in an environment variable (`ZENROWS_API_KEY`) and load it at runtime.
If using `async` methods, define an `async def main():` function containing your async calls and run it with `asyncio.run(main())`.
Implement retry logic with exponential backoff (using the `retries` parameter) or reduce your concurrency. Check your ZenRows dashboard for plan limits.
Enable `js_render: true`, `premium_proxy: true`, or add a `referer` header. You might also need to use `wait_for` or `wait` parameters for dynamically loaded content.
Verify your ZenRows API key and proxy credentials from your dashboard. Ensure the proxy URL format is `http://username:password@proxy-host:port` and the protocol/port match (e.g., 1337 for HTTP, 1338 for HTTPS).