Playground Sign in Start free

How to Find All Pages on a Website

Download runnable code Sign in to prefill your key
Find all pages of a website Download
1

Two lists, then the difference

To find all pages on a website, combine two lists: the URLs in its sitemaps, and the URLs you reach by following its links. Pages in the sitemap that no link reaches are orphans; linked pages missing from the sitemap are gaps. With the Crawl API the sitemap list costs nothing (ujeebu.com: 950 URLs, 0 credits), and a free quote gives the most the link crawl can cost before it starts.

StepCallCost
1. List the sitemap URLsPOST /crawl with "mode": "sitemap"0 credits
2. Quote the link crawlPOST /crawl/quote0 credits
3. Crawl the linksPOST /crawl with max_creditsat most the quote
4. Compare the two listsyour code0 credits
A crawl bill you can trust

A free quote gives the most a crawl can cost before it starts, and max_credits is a hard cap: the job stops before a page that would pass it. Plain HTML without JavaScript costs 1 credit a page; failed and blocked pages are not billed.

Every call goes to https://api.ujeebu.com/crawl with your key in the ApiKey header; the scripts read it from UJEEBU_API_KEY. You need Python 3 with requests, or Node.js 18 or later. Planning a migration? The use case Content inventory for migrations starts from this list.

2

Extract all URLs from the sitemaps

A job with "mode": "sitemap" works as a sitemap URL extractor: it reads the site's sitemap files, sitemap indexes included, and records every in-scope URL with the state listed. No page is fetched and the job costs nothing. Start it, wait for finished, then read the URLs with the page cursor.

# Start the listing (no page is read, 0 credits)
curl -s -X POST https://api.ujeebu.com/crawl \
  -H "ApiKey: YOUR_API_KEY" -H "Content-Type: application/json" \
  -d '{"urls": ["https://ujeebu.com/"], "mode": "sitemap", "scope": {"max_pages": 1000}}'

# When GET /crawl/JOB_ID says "finished": true, read the URLs 50 at a time
curl -s "https://api.ujeebu.com/crawl/JOB_ID/pages?after=0&limit=50" -H "ApiKey: YOUR_API_KEY"
Response (trimmed)
{
  "job_id": "c_2111c484-8e22-43e8-81c0-0f05fc4a9625",
  "status": "completed",
  "finished": true,
  "pages": [
    {"seq": 1, "url": "https://ujeebu.com/", "state": "listed", "depth": 0,
     "discovered_from": "https://ujeebu.com/sitemap.xml", "credits": 0},
    {"seq": 2, "url": "https://ujeebu.com/pricing", "state": "listed", "depth": 0,
     "discovered_from": "https://ujeebu.com/sitemap.xml", "credits": 0}
  ],
  "next_after": 50,
  "has_more": true
}

Counting the URLs by their first path segment shows where the pages are:

Output
Sitemap: 950 URLs, 0 credits
  /ai-index     364
  /scrape       197
  /recipes      149
  /data          60
  /blog          45
  /docs          23
3

Quote the link crawl

A sitemap lists what the site declares, not what visitors can reach. The second list comes from following links. Here the crawl covers the blog: it starts at /blog, follows links inside /blog/** only ("use_sitemap": false, so the comparison means something), and reads plain HTML, the cheapest page, where every <a href> counts. POST /crawl/quote takes the same body and creates nothing.

crawl = {
    "urls": [SITE.rstrip("/") + SECTION],
    "scope": {
        "include": [SECTION + "/**"],
        "exclude": [SECTION + "?*", SECTION + "/**?*"],   # ?tag= and ?author= views: copies of the list pages
        "max_depth": 5,
        "max_pages": 200,
    },
    "use_sitemap": False,      # links only, so the comparison with the sitemap means something
    "format": "html",
    "page": {"js": False},     # plain HTML: the cheapest page, and every <a href> is counted
}
quote = api("POST", "/crawl/quote", json=crawl)
Response
{
  "estimate": true,
  "mode": "crawl",
  "format": "html",
  "js": false,
  "credits_per_page": 1,
  "max_pages": 200,
  "max_depth": 5,
  "credits_ceiling": 200,
  "note": "Credits per page come from a price table and are an estimate: each page is billed by the page endpoint for what it actually used (...)"
}
FieldWhat it tells you
credits_per_pageThe price of one page with these settings (format, JavaScript, proxy).
credits_ceilingcredits_per_page times max_pages, or max_credits when that is lower: the most the crawl can cost.
sitemap.in_scope_urlsWith "use_sitemap": true, the sitemap URLs that match the scope.

A pattern matches the whole path: * stays inside one segment, ** crosses segments, and /blog/** also matches /blog itself. A pattern with ? is matched against the path and the query string. All the rules are on Scope and rules.

4

Crawl the links under a hard cap

Start the job with max_credits set to the quote's credits_ceiling. Each page counts once, so this cap reads every page the quote priced, and the bill cannot pass it.

job = api("POST", "/crawl", json={**crawl, "max_credits": quote["credits_ceiling"]})
job = wait(job["job_id"])
crawled = {clean(p["url"]): p for p in page_records(job["job_id"])}
print(f"Link crawl: {job['counts']['done']} pages read, {job['credits_used']} credits, "
      f"stop_reason={job['stop_reason']}")
Exclude filter and tag URLs up front

Our first run had no exclude patterns. It read 113 pages, and 64 of them were /blog?tag=... and /blog?author=... views whose canonical link points to /blog. A duplicate is only known after the page is read: the job recorded each one as duplicate, and each was billed like any page read. Exclude filter, tag and sort query patterns in the scope, as above, and they are never read.

5

Compare the lists: orphan pages and gaps

With both lists in hand, the difference is a set operation. Normalise the URLs first (no fragment, no trailing slash) so the same page is not counted twice.

listed = {u for u in sitemap if in_section(u)}
found = {u for u, p in crawled.items() if p["state"] == "done"}
orphans = sorted(listed - set(crawled))    # in the sitemap, reached by no link
unlisted = sorted(found - listed)          # linked and live, missing from the sitemap
Found inMeaningWhat to do
Both listsDeclared and reachable.Nothing.
Sitemap onlyAn orphan: no internal link leads to it (or it sits deeper than max_depth).Link to it, or drop it from the sitemap if it should go.
Links onlyReachable but not declared to search engines.Add it to the sitemap, or keep it out on purpose (feeds, pagination).
6

The complete script

The four steps in one file, writing all-pages.csv (url, in_sitemap, found_by_links, state, http_status, title). Change SITE and SECTION for your site.

#!/usr/bin/env python3
"""Find all pages of a website with the Ujeebu Crawl API.

1. Extract every URL from the site's sitemaps (sitemap mode: no page is read, 0 credits).
2. Quote a crawl that follows the links of one section (free), then run it capped at the quote.
3. Compare the two lists: orphans (in the sitemap, reached by no link) and pages missing from the
   sitemap (linked and live). Everything goes to all-pages.csv.

    pip install requests
    UJEEBU_API_KEY=your-key python3 find_all_pages.py
"""
import collections
import csv
import os
import time
from urllib.parse import urlparse

import requests

API_KEY = os.environ.get("UJEEBU_API_KEY", "YOUR_API_KEY")
API = "https://api.ujeebu.com"

SITE = "https://ujeebu.com/"
SECTION = "/blog"      # the part of the site to crawl link by link

http = requests.Session()
http.headers["ApiKey"] = API_KEY


def api(method, path, **kwargs):
    """Call the Crawl API. A GET is tried again after a network error: polling runs for minutes."""
    for attempt in range(1, 4):
        try:
            response = http.request(method, API + path, timeout=60, **kwargs)
            break
        except requests.ConnectionError:
            if method != "GET" or attempt == 3:
                raise
            time.sleep(5 * attempt)
    if response.status_code >= 400:
        raise SystemExit(f"{method} {path}: {response.status_code} {response.text}")
    return response.json()


def wait(job_id):
    """Poll the job until it has finished (every page ended, archive built)."""
    while True:
        job = api("GET", f"/crawl/{job_id}")
        if job["finished"]:
            return job
        time.sleep(5)


def page_records(job_id):
    """Every page record of a finished job, 50 at a time, following the cursor."""
    after = 0
    while True:
        batch = api("GET", f"/crawl/{job_id}/pages", params={"after": after, "limit": 50})
        yield from batch["pages"]
        if not batch["has_more"]:
            return
        after = batch["next_after"]


def clean(url):
    """One spelling per URL: no fragment, no trailing slash (except on the root)."""
    url = url.split("#")[0]
    return url if urlparse(url).path in ("", "/") else url.rstrip("/")


def in_section(url):
    path = urlparse(url).path.rstrip("/")
    return path == SECTION or path.startswith(SECTION + "/")


# 1. Every URL in the sitemaps, for 0 credits.
listing = api("POST", "/crawl", json={"urls": [SITE], "mode": "sitemap", "scope": {"max_pages": 1000}})
listing = wait(listing["job_id"])
sitemap = {clean(p["url"]) for p in page_records(listing["job_id"])}
sections = collections.Counter("/" + urlparse(u).path.strip("/").split("/")[0] for u in sitemap)
print(f"Sitemap: {len(sitemap)} URLs, {listing['credits_used']} credits")
for section, count in sections.most_common(6):
    print(f"  {section:<12}{count:>5}")

# 2. Follow the links of one section. The quote gives the most it can cost; the cap holds it there.
crawl = {
    "urls": [SITE.rstrip("/") + SECTION],
    "scope": {
        "include": [SECTION + "/**"],
        "exclude": [SECTION + "?*", SECTION + "/**?*"],   # ?tag= and ?author= views: copies of the list pages
        "max_depth": 5,
        "max_pages": 200,
    },
    "use_sitemap": False,      # links only, so the comparison with the sitemap means something
    "format": "html",
    "page": {"js": False},     # plain HTML: the cheapest page, and every <a href> is counted
}
quote = api("POST", "/crawl/quote", json=crawl)
print(f"Quote: {quote['credits_per_page']} credit a page, at most {quote['credits_ceiling']} credits")
job = api("POST", "/crawl", json={**crawl, "max_credits": quote["credits_ceiling"]})
job = wait(job["job_id"])
crawled = {clean(p["url"]): p for p in page_records(job["job_id"])}
print(f"Link crawl: {job['counts']['done']} pages read, {job['credits_used']} credits, "
      f"stop_reason={job['stop_reason']}")

# 3. Compare the two lists.
listed = {u for u in sitemap if in_section(u)}
found = {u for u, p in crawled.items() if p["state"] == "done"}
orphans = sorted(listed - set(crawled))    # in the sitemap, reached by no link
unlisted = sorted(found - listed)          # linked and live, missing from the sitemap
with open("all-pages.csv", "w", newline="") as f:
    out = csv.writer(f)
    out.writerow(["url", "in_sitemap", "found_by_links", "state", "http_status", "title"])
    for url in sorted(listed | set(crawled)):
        page = crawled.get(url, {})
        out.writerow([url, url in listed, url in crawled, page.get("state", ""),
                      page.get("http_status", ""), page.get("title", "")])
print(f"{SECTION}: {len(listed)} in the sitemap, {len(found)} found by links, {len(listed & found)} in both")
print(f"  {len(orphans)} orphans (in the sitemap, no link to them)")
for url in orphans[:5]:
    print(f"    {url}")
print(f"  {len(unlisted)} pages missing from the sitemap")
for url in unlisted[:5]:
    print(f"    {url}")
Run it
# Python 3, the script saved as find_all_pages.py
pip install requests
UJEEBU_API_KEY=your-key python3 find_all_pages.py

# Node.js 18 or later, the script saved as find-all-pages.js
UJEEBU_API_KEY=your-key node find-all-pages.js
Output (trimmed)
Sitemap: 950 URLs, 0 credits
  /ai-index     364
  /scrape       197
  /recipes      149
  /data          60
  /blog          45
  /docs          23
Quote: 1 credit a page, at most 200 credits
Link crawl: 49 pages read, 49 credits, stop_reason=completed
/blog: 45 in the sitemap, 49 found by links, 45 in both
  0 orphans (in the sitemap, no link to them)
  4 pages missing from the sitemap
    https://ujeebu.com/blog/page/2
    https://ujeebu.com/blog/page/3
    https://ujeebu.com/blog/page/4
    https://ujeebu.com/blog/rss

With the exclude patterns the link crawl read 49 pages for 49 credits, well under the quote's ceiling; the first run without them read 113 pages for the same result. The four gaps are list pages and a feed, which a sitemap usually leaves out on purpose; no blog post was an orphan.

7

What a stop at the cap looks like

Set max_credits below the quote and the job stops before a page that would pass it. A Markdown sample of the same blog, capped at 50 credits:

Job status and a page left unread (trimmed)
{
  "status": "completed",
  "stop_reason": "max_credits",
  "counts": {"discovered": 45, "done": 5, "failed": 0, "skipped": 40, "pending": 0, "in_progress": 0},
  "credits_used": 50,
  "max_credits": 50,
  "errors": {"stopped": 40}
}

{"seq": 45, "url": "https://ujeebu.com/blog/how-to-extract-clean-text-from-html",
 "state": "skipped", "error_class": "stopped", "credits": 0,
 "error": "not fetched: the job stopped (max_credits)"}

The pages the job never started are recorded with error_class stopped and cost nothing. Next: build a content inventory from the crawl, generate an llms.txt file, or convert the pages to Markdown.

Size your own site

The free sizer lists a site's sitemap URLs and quotes the crawl before you spend a credit.

?

Frequently Asked Questions

How do I find all pages on a website?

Combine two lists: the URLs in the site's sitemaps and the URLs you reach by following its links. With the Crawl API the sitemap list costs nothing, and a link crawl of plain HTML costs 1 credit a page, capped at the free quote. Pages in the sitemap that no link reaches are orphans; linked pages missing from the sitemap are gaps to fix.

How do I extract all URLs from a sitemap?

Start a job with "mode": "sitemap". It reads the site's sitemap files, sitemap indexes included, and lists every in-scope URL with the state "listed", without reading a single page. It costs 0 credits: our listing of ujeebu.com returned 950 URLs.

How do I find orphan pages on a website?

An orphan page is in the sitemap but no internal link leads to it. List the sitemap URLs, crawl the site by its links only ("use_sitemap": false), and keep the sitemap URLs the crawl never reached. Give the crawl enough max_depth, or deep pages will look like orphans too.

How much does it cost to crawl a whole website?

A free quote gives the most a crawl can cost before it starts, and max_credits is a hard cap: the job stops before a page that would pass it. Plain HTML without JavaScript costs 1 credit a page, HTML with JavaScript 5 credits, Markdown 10 credits. Failed and blocked pages are not billed.

Can I list all pages of a website without crawling it?

Only the pages its sitemaps declare. Sitemap mode lists them for free, but a sitemap leaves out pages that only links reach, so a link crawl completes the list.