Tutorial 3 min read

Jina Reader Python Tutorial: Read and Validate a Web Page

Read a known URL with Jina Reader in Python, preserve its source, and check missing content, HTTP failures and output format before using it in an LLM.

(Updated: ) • 474 words

To read a known web page with Jina Reader in Python, request https://r.jina.ai/ followed by the full source URL. Keep the returned text with its source address, then check that the passages your application needs survived extraction. This tutorial covers one URL at a time; it does not implement site discovery or browser actions.

Request a reviewed public URL

Install requests with python -m pip install requests. The example accepts an optional JINA_API_KEY environment variable. Check the current official account limits before choosing a worker count. A timeout, non-success HTTP status, or empty body is a failed extraction, not a valid document.

import os
from urllib.parse import urlsplit
import requests

def read_jina(url, session=requests):
    if urlsplit(url).scheme != "https":
        raise ValueError("Use a reviewed public HTTPS URL")
    headers = {"Accept":"text/plain"}
    if os.environ.get("JINA_API_KEY"):
        headers["Authorization"] = "Bearer " + os.environ["JINA_API_KEY"]
    response = session.get("https://r.jina.ai/" + url, headers=headers, timeout=60)
    response.raise_for_status()
    if not response.text.strip():
        raise ValueError("Empty Jina response")
    return {"source_url":url, "text":response.text}

if __name__ == "__main__":
    result = read_jina("https://www.searchcans.com/reader-api/")
    print(result["source_url"], len(result["text"]))

Validate the output before giving it to an LLM

Choose literal checks from the source: the main section heading, a table row including its unit, and any code block or link needed to answer the task. Record which checks failed. A response that contains readable prose can still omit the exact table the user asked about. Keep a source timestamp alongside the text and revalidate it when freshness matters.

For a retry, log the HTTP status and attempt count first. Do not silently loop on an authorization failure or assume a successful second call returned the same version. A bounded retry policy belongs in the application; this small example deliberately leaves retries visible to the caller.

Keep reading, discovery and selection separate

A Jina read request starts with a URL. If the application only knows a question, discover candidate URLs first and review their relevance and permitted use. For a SearchCans search response, the result list is data.organic and each URL is in link; for its Reader response, text is in data.markdown. Do not reuse a parser written for Jina plain text as a JSON parser.

For vendor selection, see Jina Reader alternatives by task. For billing units and workload calculations, see Jina Reader and SearchCans pricing comparison. The broader URL-to-Markdown Python tutorial covers the SearchCans request contract.

Sources and reproduction

Tags:

Tutorial Reader API LLM RAG Web Scraping Markdown
SearchCans Team

SearchCans Team

SERP API & Reader API Experts

The SearchCans engineering team builds high-performance search APIs serving developers worldwide. We share practical tutorials, best practices, and insights on SERP data, web scraping, RAG pipelines, and AI integration.

Ready to build with SearchCans?

Test SERP API and Reader API with 100 free credits. No credit card required.