Skip to main content
Extract web data with enterprise-grade performance using Undici’s HTTP/1.1 client and Zenrows’ Fetch. This guide demonstrates how to leverage Undici’s superior performance with Zenrows’ robust scraping infrastructure to build high-speed web scraping applications.

What Is Undici?

Undici is a fast, reliable HTTP/1.1 client written from scratch for Node.js. It provides significant performance improvements over traditional HTTP clients, such as Axios and node-fetch, making it ideal for high-throughput scraping applications. Undici supports advanced features like HTTP/1.1 pipelining, connection pooling, and multiple request methods.

Key Benefits of Integrating Undici with Zenrows

The undici-zenrows integration brings the following advantages:
  • Superior Performance: Undici delivers up to 3x better performance compared to traditional HTTP clients, making your scraping operations faster and more efficient.
  • Advanced Connection Management: Built-in connection pooling and HTTP/1.1 pipelining capabilities optimize resource usage for high-volume scraping.
  • Enterprise-Grade Scraping Reliability: Combine Undici’s robust HTTP handling with Zenrows’ scraping infrastructure.
  • Multiple Request Methods: Choose from request, fetch, stream, or pipeline API methods based on your specific use case requirements.
  • Memory Efficient: Stream-based processing reduces memory overhead for large-scale scraping operations.
  • TypeScript Support: Full TypeScript support for a better development experience and type safety.

Getting Started: Basic Usage

Let’s start with a simple example that uses Undici to scrape the Antibot Challenge page through Zenrows’ Fetch.

Step 1: Install Undici

Install the undici package using npm:

Step 2: Set Up Your Project

You’ll need your Zenrows API key, which you can get from the Request builder dashboard. Zenrows Request Builder Only
You can explore different parameter configurations using the Request Playground dashboard, then apply those settings in your Undici implementation. For a complete list of available parameters and their descriptions, refer to the API Reference documentation.
Create a new file and import the necessary modules.
Node.js

Step 3: Make Your First Request

Use Undici’s request method to call Zenrows’ Fetch:
Node.js
Understanding the ParametersIn the code above, we’re using two key parameters to handle the antibot:js_render: "true": Activates JavaScript execution to handle dynamic content and render the page completelypremium_proxy: "true": Routes requests through high-quality residential IP addresses for protected accessThese parameters work together for reliable access to sites with sophisticated anti-bot protection. For a comprehensive list of all available parameters and their usage, check the parameter overview table.
Replace YOUR_ZENROWS_API_KEY with your actual API key and run the script:
The script will successfully bypass the antibot and return the HTML content:
Output
Perfect! You’ve successfully integrated Undici with Zenrows to bypass antibot protection.

Complete Example: E-commerce Product Scraper

Now let’s build a complete scraper for an e-commerce site to demonstrate practical use cases with Undici and Zenrows.

Step 1: Scrape the E-commerce Site

Let’s start by scraping an e-commerce demo site to see how Undici handles real-world scenarios. We’ll extract the complete HTML content of the page:
Node.js
This will return the complete HTML content of the e-commerce page.
Output

Step 2: Parse the Scraped Data

Now that you can successfully scrape the site, let’s extract specific product information using CSS selectors. We’ll use Zenrows’ css_extractor parameter to get structured data:
Node.js
The response will be a JSON object containing the extracted product names:
Output

Step 3: Export Data to CSV

Finally, save the scraped product data to a CSV file for further analysis:
Node.js
Run the script and you’ll get a CSV file containing all the product names: e_commerce demo csv Congratulations! You now have a complete working scraper that can extract product data from an e-commerce site and export it to a CSV file.

Next Steps

You now have a complete foundation for high-performance web scraping with Undici and Zenrows. Here are some recommended next steps to optimize your scraping operations:
  • Undici Documentation: Explore Undici’s advanced features like HTTP/1.1 pipelining, custom dispatchers, and performance optimizations.
  • Complete API Reference: Explore all available Zenrows parameters and advanced configuration options to customize your Undici requests for specific use cases.
  • JavaScript Instructions Guide: Learn how to perform complex page interactions like form submissions, infinite scrolling, and multi-step workflows using Zenrows’ browser automation.
  • Output Formats and Data Extraction: Master advanced data extraction with CSS selectors, convert responses to Markdown or PDF, and capture screenshots using Undici’s streaming capabilities.

Getting Help

Request failures can happen for various reasons when using Undici with Zenrows. For detailed troubleshooting guidance, visit our comprehensive troubleshooting guide and check Undici’s documentation for HTTP client-specific issues. If you’re still facing issues despite following the troubleshooting tips, our support team is available to help you. Use the chatbox in the Request Playground dashboard or contact us via email to get personalized help from Zenrows experts. When contacting support, always include the X-Request-Id from your response headers to help us diagnose issues quickly.

Frequently Asked Questions (FAQ)

Enable both js_render and premium_proxy parameters in your Zenrows API calls. This combination offers the highest success rate against sophisticated antibot protection by simulating real browser behavior and utilizing high-quality residential IP addresses.
Enable the js_render parameter in your Zenrows API calls. This uses a real browser to execute JavaScript and capture the fully rendered page. Combine with Undici’s efficient request handling for optimal performance on modern web applications.
Absolutely! Undici’s stream() and pipeline() methods work perfectly with Zenrows. This is especially useful for processing large responses efficiently without loading everything into memory.
undici.request() provides better performance and more control over the request/response lifecycle, while undici.fetch() offers a more familiar API similar to browser fetch. For maximum performance with Zenrows, use undici.request().
Use the css_extractor parameter in your Zenrows API calls to extract content using CSS selectors directly. The response will be JSON instead of HTML, making it easier to process with Undici.
Yes! Undici’s performance characteristics make it excellent for real-time monitoring. Use session management with Zenrows’ session_id parameter and implement efficient polling with Undici’s connection pooling.
Yes! All Zenrows features work with Undici.