Skip to main content
Integrate Zenrows with LlamaIndex to enable your RAG applications to access, index, and synthesize up-to-date web content from any website, including those with anti-bot protection and dynamic content.

What Is LlamaIndex?

LlamaIndex is an open-source framework that connects LLMs to external data sources, databases, documents, and APIs. It provides tools for data ingestion, indexing, and query-based retrieval, commonly used to build retrieval-augmented generation (RAG) applications, which can be used to feed AI agents with up-to-date information.

Key Integration Benefits

  • Uninterrupted access to data: Build a reliable data layer that can access information from any website without getting blocked by anti-bot measures.
  • Real-time information retrieval: Extract real-time data faster and more efficiently before it becomes stale.
  • Direct extraction of LLM-friendly data: Get pre-formatted LLM-friendly data, such as the Markdown or JSON version of any website. Zenrows also enables the extraction of specific data directly.
  • Less code, more data: Scrape data continuously with an auto-managed and auto-scaled solution with a simple API call.
  • Business-oriented development: No extra engineering time and resources will be wasted on debugging or fixes.
  • Handle dynamic content easily: Access heavily dynamic websites without performing complex waits and user simulations.
  • Borderless data retrieval: Expose AI applications to data from any specific location without IP limitations using residential proxies with geo-targeted IPs.

Use Cases of LlamaIndex-Zenrows Integration

  • Real-time price monitoring: Use Zenrows to scrape prices from several product sites in real-time and synthesize a comprehensive comparison with an LLM.
  • Competitive research: Scrape several competitors’ offerings, product launches, strategies, and more with Zenrows and draw a correlation between the data using an LLM.
  • News and trends summarization: Use Zenrows to aggregate news, trends, hashtags, and more, across similar platforms. Summarize the aggregated data with an LLM and extract specific insights.
  • Dynamic chatbots: Build a chatbot that can access the web or specific web pages in real time to provide updated information.

Getting Started: Basic Usage

This example demonstrates how to extract content from a protected website using the ZenRowsWebReader. The ZenRowsWebReader enables you to use the official Zenrows Fetch as a data loader for web scraping in LlamaIndex.
1

Install the package

2

Basic implementation

Import ZenRowsWebReader from llama-index-readers-web. Initialize ZenRowsWebReader as a reader instance. Then, set your Zenrows parameters through this instance.Load the target site as a document and return its content in the specified format (Markdown response):
Python
The code returns a Markdown format of the target site, as shown:
Markdown

Advanced Usage: Building a Simple RAG System

This example creates a simple RAG system that indexes multiple websites and responds to queries using the collected data. You’ll need an OpenAI API key to use the LLM and embedding features. So, prepare your OpenAI API key.
1

Install the packages

2

Set up ZenRowsWebReader

Import the required packages and specify your Zenrows and OpenAI API keys. Initialize ZenRowsWebReader using the desired Zenrows parameters. Include js_render and premium_proxy to effectively bypass anti-bot measures.
Python
3

Set up a vector index

Specify the target URLs in a list, load their web pages as documents, and create a vectorized index of the documents:
Python
4

Query the index

Initialize a query engine from the index, pass a prompt to query it, and return the query response:
Python
5

Complete code

Python
LlamaIndex uses Zenrows to retrieve each website’s information in Markdown format, vectorizes it, and synthesizes a response based on the query.Here’s a sample response from the above code:
Markdown
Congratulations! 🎉You’ve integrated Zenrows with LlamaIndex.

API Reference

For complete parameter documentation and details, see the official Zenrows’ Fetch Reference.

Troubleshooting

The returned response is incomplete:

  • Solution 1: Ensure you activate js_render and premium_proxy to bypass anti-bot measures and scrape reliably.
  • Solution 2: Apply enough wait time to allow dynamic content to load completely before scraping. If a specific element holding the required data loads slowly, you can also wait for it using the wait_for parameter.
  • Solution 3: If only partial responses are returned, the LLM may be missing relevant information in the chunk. Adjust the engine query retrieval by increasing the number of chunks the LLM receives from the documents. Increase the chunk by adding a similarity_top_k parameter to the query engine as shown:
    Python
  • Solution 4: If you’ve used the css_extractor parameter to target specific elements, ensure you’ve entered the correct selectors.

API key or authentication error

  • Solution: Ensure you’ve supplied your LLM (e.g., OpenAI) and Zenrows API keys correctly.

Module not found

  • Solution: Install all the required modules:
    • llama-index-readers-web
    • llama-index-llms-openai
    • llama-index-embeddings-openai

Resources

Frequently Asked Questions (FAQ)

The use cases of LlamaIndex-Zenrows integration are diverse. However, the primary application is to enable AI applications to access and reason over live, real-world web data, even from sites with anti-bot protections or dynamic content.
Yes, you can scrape data from specific elements using their CSS selectors via the css_extractor parameter.
Yes. The ZenRowsWebReader inherits all the features and capabilities of the Zenrows Fetch.
LlamaIndex supports many popular LLMs, such as Groq, OpenAI, Anthropic, and more. Check LlamaIndex’s official documentation for the supported LLMs.
LlamaIndex isn’t explicitly designed for web scraping information from websites. However, you can add a scraping layer to LlamaIndex by pairing it with a web scraping tool like Zenrows, which provides it with anti-bot bypass capabilities.