The script on this page scrapes web pages with Python and imports nothing outside the standard library. It has no HTML parser and no CSS selectors. It sends each URL to the Spider scrape endpoint and gets the page back as markdown, the short form of the request our guide to web scraping walks through step by step.
It returned 25 of 25 pages as markdown in each of four runs. We ran it against the same 25 pages on five documentation sites, three times on November 16, 2026 and once on the morning of November 17. Each run took under a minute, one request at a time, and the fastest, on November 17, took 33.8 seconds. All four runs cost under a cent each on the pay as you go meter. Cost varies by site. These were static pages that need no browser. The whole script is below, unchanged from the four runs.
What the four runs returned
| Started (UTC) | Pages returned | Wall time | Median page | Slowest page | Words | Cost |
|---|---|---|---|---|---|---|
| Nov 17, 10:37 | 25 of 25 | 33.8 s | 1.10 s | 2.93 s | 37,465 | $0.006884 |
| Nov 16, 16:58:55 | 25 of 25 | 34.0 s | 1.24 s | 2.56 s | 37,415 | $0.006863 |
| Nov 16, 16:28:20 | 25 of 25 | 54.0 s | 1.44 s | 6.71 s | 37,415 | $0.006889 |
| Nov 16, 16:12:22 | 25 of 25 | 57.5 s | 1.69 s | 8.61 s | 37,415 | $0.006896 |
Newest first. Each run used the script below, unchanged, as python3 -I scrape_docs.py. The November 16 runs used Python 3.14.7. Wall time runs from the first request sent to the last answer read. Cost is the sum of costs.total_cost over the 25 answers on the pay as you go meter.
Every page answered with status 200 and markdown in all four runs. The word total was 37,415 in each run on November 16 and 37,465 on November 17, so expect your own word counts and hashes to differ from ours.
The fastest run took 33.8 seconds and the slowest 57.5. A script that waits for each answer before it sends the next pays for every slow page in full, so read the four times as a range. To go faster, send the requests in parallel with concurrent.futures.
Divided by its 25 pages, each run cost about $0.00028 a page, and the four totals sit less than four thousandths of a cent apart. We computed both figures from the table. These are plain fetches of static pages. A page that only renders in a browser needs request: "browser" and costs more. The Unlimited plan is priced by requests at once and not by page, from $40 a month for 2 in http mode.
The script
The script is 80 lines of standard library Python. Save it as scrape_docs.py, set your key and run it with python3 scrape_docs.py.
#!/usr/bin/env python3
"""Fetch documentation pages as markdown through the Spider API, one request per page.
export SPIDER_API_KEY=... # from https://spider.cloud/api-keys
python3 scrape_docs.py
Python 3.8 or later, standard library only. Prints one line per page and a total.
"""
import hashlib
import json
import os
import time
import urllib.error
import urllib.request
URLS = [
"https://fastapi.tiangolo.com/",
"https://fastapi.tiangolo.com/features/",
"https://fastapi.tiangolo.com/learn/",
"https://fastapi.tiangolo.com/python-types/",
"https://fastapi.tiangolo.com/async/",
"https://docs.astro.build/ar/astro-courses/",
"https://docs.astro.build/ar/basics/astro-components/",
"https://docs.astro.build/ar/basics/astro-pages/",
"https://docs.astro.build/ar/basics/layouts/",
"https://docs.astro.build/ar/basics/project-structure/",
"https://docs.docker.com/security/security-announcements/",
"https://docs.docker.com/get-started/tutorials/run-an-app/",
"https://docs.docker.com/guides/dhi-vex-walkthrough/",
"https://docs.docker.com/reference/api/ai-governance-audit-logs/latest/",
"https://docs.docker.com/reference/api/ai-governance/latest/",
"https://pydantic.dev/docs/",
"https://pydantic.dev/docs/ai/api/models/anthropic/",
"https://pydantic.dev/docs/ai/api/models/base/",
"https://pydantic.dev/docs/ai/api/models/batch/",
"https://pydantic.dev/docs/ai/api/models/bedrock_mantle/",
"https://vite.dev/acknowledgements",
"https://vite.dev/blog",
"https://vite.dev/blog/announcing-vite2",
"https://vite.dev/blog/announcing-vite3",
"https://vite.dev/blog/announcing-vite4-3",
]
BODY = {"request": "http", "return_format": "markdown", "cache": False}
KEY = os.environ["SPIDER_API_KEY"]
def scrape(url):
req = urllib.request.Request(
"https://api.spider.cloud/scrape",
data=json.dumps(dict(BODY, url=url)).encode(),
headers={"Authorization": "Bearer " + KEY, "Content-Type": "application/json"},
)
try:
with urllib.request.urlopen(req, timeout=120) as resp:
pages = json.loads(resp.read())
except (urllib.error.URLError, TimeoutError, ValueError):
return None
return pages[0] if isinstance(pages, list) and pages else None
print("status words cost_usd seconds sha256_12 url")
start = time.time()
returned = words = 0
cost = 0.0
for url in URLS:
t0 = time.time()
page = scrape(url)
secs = time.time() - t0
if page is None:
print(f"ERR 0 0 {secs:.2f} - {url}")
continue
text = page.get("content") or ""
price = (page.get("costs") or {}).get("total_cost") or 0
n = len(text.split())
returned += page.get("status") == 200 and bool(text)
words += n
cost += price
digest = hashlib.sha256(text.encode()).hexdigest()[:12]
print(f"{page.get('status')} {n} {price:.8f} {secs:.2f} {digest} {url}")
print(f"pages returned {returned} of {len(URLS)}, wall {time.time() - start:.2f} s, words {words}, cost ${cost:.6f}")The request body has three settings, all from the API reference. request: "http" fetches the page without running JavaScript, which is enough for static documentation. return_format: "markdown" returns the page as markdown in the content field. cache: false turns off the API’s HTTP cache, so each of the four runs fetched every page again and none read a stored copy.
The scrape endpoint answers with a one element array. The script reads status, content and costs.total_cost from that element and prints the first 12 characters of a SHA-256 of the markdown, so you can compare two runs line by line.
Which pages, and why these
The 25 URLs are the first five entries in the sitemap of each of five documentation sites: FastAPI, Astro, Docker, Pydantic and Vite. We wrote the list down before the first request and did not change it after. That is why all five Astro URLs are under /ar/, the Arabic edition, which comes first in that sitemap.
Before the first run we read each host’s robots.txt through the API. A URL would have come off the list if its host’s robots.txt disallowed the path or asked for a crawl delay over five seconds, or if the request for the file failed. None did. FastAPI and Vite serve no robots.txt, so those two hosts state no rules.
Using the official Python client
We also ran the same loop with the Python client, spider-client 0.1.93 from PyPI, in a fresh virtual environment. The loop, the counting and the hashing stayed the same. This is the request for one page:
from spider import Spider
app = Spider() # reads SPIDER_API_KEY from the environment
BODY = {"request": "http", "return_format": "markdown", "cache": False}
pages = app.scrape_url("https://fastapi.tiangolo.com/", params=BODY)
page = pages[0]
print(page["status"], len(page["content"].split()), page["costs"]["total_cost"])The client run started at 16:13:21 UTC on November 16, between the first and second script runs, and returned 25 of 25 pages. Its markdown matched the first urllib run on all 25 by hash, 37,415 words, and it cost $0.006874.
In version 0.1.93, as its source reads, the client retries a failed call up to five times without being asked. The urllib script makes one attempt per URL. It prints ERR when the request or its JSON fails and the page’s own status when the target fails, so a retry is yours to add.
Run it on your own pages
The 25 pages are static documentation, fetched one at a time from one machine. Swap in your own URLs, and set request: "browser" for pages that build themselves with a script. To run the script yourself, create an API key and export it as SPIDER_API_KEY. To see the markdown for one page first, run it in the web scraper, which needs no key.
Frequently asked questions
Can I scrape web pages in Python without installing anything?
Yes. The script on this page imports nothing outside Python's standard library and runs on Python 3.8 or later. It sends each URL to an API that fetches the page and returns markdown, so there is no HTML parser to install. It returned 25 of 25 pages from five documentation sites in each of four runs, three on November 16, 2026 and one on November 17.
How long does a Python scraper take for 25 pages?
Under a minute in each of our four runs, one request at a time. The fastest took 33.8 seconds on November 17, 2026, and the three runs on November 16 took 34.0, 54.0 and 57.5 seconds. The median page took 1.10 to 1.69 seconds. Send requests in parallel with concurrent.futures if the total matters.
Should I use the Spider Python client or plain urllib?
Both returned the same 25 pages in our run. We ran the same loop once with spider-client 0.1.93 from PyPI on November 16, 2026, and its markdown matched the first urllib run on 25 of 25 pages by hash. The client retries a failed call up to five times without being asked. The urllib version has no dependency and shows every field it sends.
What does it cost to scrape 25 pages this way?
From $0.16 per 1,000 pages. Cost varies by site. In our four runs on November 16 and 17, 2026, each run of 25 documentation pages cost between $0.006863 and $0.006896 on the pay as you go meter. Each run's cost is the sum of the costs.total_cost field over its 25 answers. Divided by 25, that is about $0.00028 a page, a figure we computed. These were plain HTTP fetches of static pages. A page that needs a browser costs more. The Unlimited plan is priced by requests at once and not by page, from $40 a month for 2 in http mode.
Sources
- Measured runs, 2026-11-16, 16:12 to 16:59 UTC: the script below run three times and the client version once, through the Spider API scrape endpoint. One more run of the script on 2026-11-17 at 10:37 UTC
- Spider OpenAPI file, the request, return_format and cache parameters and the costs field of a scrape answer
- spider-client on PyPI, the official Python client, version 0.1.93 in this run
- Python documentation for urllib.request, the only HTTP module the script uses
- How web scraping works: the cost of a plain fetch and of a rendered fetch on the same pages, measured 2026-11-16
- Spider pricing guide, what pages cost: light static pages from $0.16 per 1,000, measured 2026-11-17 on 25 catalogue pages of a practice site with the cache off
- Spider pricing page, the Unlimited plan's price by requests at once