Use a sitemap as a URL-discovery source, not as proof that a page exists or that you may crawl it. Start with the site’s /robots.txt, follow every Sitemap: declaration, identify whether each XML file is a URL set or a sitemap index, recursively collect <loc> values, then normalize, deduplicate, and validate the resulting URLs before making a crawl plan.
What a sitemap can—and cannot—tell you
A sitemap is an XML document published by a site to help systems discover URLs. Google describes it as a discovery aid; listing a URL does not guarantee that a search engine will crawl or index it. The same limitation matters for your own scraper: a listed URL may be stale, redirected, blocked, unavailable, duplicated, or unsuitable for your job.
Finding a URL is therefore a separate step from deciding whether to request it. Treat the extracted list as candidate targets. Check the site’s terms, applicable law, robots rules, authentication requirements, and your request rate before fetching pages. A sitemap is not permission to crawl.
End-to-end workflow
- Request
https://example.com/robots.txtand record every case-insensitiveSitemap:declaration. Google documents this discovery method, and crawler frameworks can use it. - If no declaration appears, try likely paths such as
/sitemap.xmlor/sitemap_index.xmlas a fallback. No universal filename is guaranteed, so treat failures as normal. - Fetch each XML file, including
.gzfiles, and parse it with namespace-aware XML logic. - Inspect the root element. A
urlsetcontains URL records; asitemapindexcontains links to child sitemap files. - For indexes, fetch every child and repeat the test recursively. Collect only
locvalues from URL sets. - Resolve, normalize, filter, and deduplicate URLs. Then validate status codes, redirects, content type, crawl constraints, and pacing before downloading page content.
Discover sitemap files through robots.txt
A robots file can contain one or more declarations, for example:
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
User-agent: *
Disallow: /private/
Sitemap: https://example.com/sitemap.xml
Sitemap: https://example.com/news-sitemap.xml
Do not assume there is only one declaration. Preserve absolute sitemap URLs exactly as published, and handle a robots response that is missing, unavailable, or malformed without treating that as evidence that no sitemap exists.
Python: fetch robots.txt and extract declarations
from urllib.parse import urljoin
import requests
def sitemap_locations(site_url: str) -> list[str]:
base = site_url.rstrip("/") + "/"
robots_url = urljoin(base, "robots.txt")
response = requests.get(robots_url, timeout=30,
headers={"User-Agent": "URLDiscovery/1.0"})
if response.status_code >= 400:
return []
locations = []
for line in response.text.splitlines():
name, separator, value = line.partition(":")
if separator and name.strip().lower() == "sitemap":
value = value.strip()
if value:
locations.append(urljoin(base, value))
return list(dict.fromkeys(locations))
print(sitemap_locations("https://example.com"))
Use a current crawler library if you need robots policy enforcement; this function only discovers declarations and does not decide which pages you are allowed to fetch.
Parse URL sets and sitemap indexes
The protocol commonly uses the namespace http://www.sitemaps.org/schemas/sitemap/0.9. Namespace-aware lookup is essential because a naive search for an unqualified loc element can return nothing. XML entities must be decoded by the XML parser, not by ad-hoc string replacement.
Complete recursive Python extractor
from collections import deque
from urllib.parse import urldefrag, urljoin, urlsplit, urlunsplit
import gzip
import io
import requests
import xml.etree.ElementTree as ET
NS = {"sm": "http://www.sitemaps.org/schemas/sitemap/0.9"}
def clean_url(value: str, base: str | None = None) -> str | None:
value = value.strip()
if not value:
return None
value = urljoin(base, value) if base else value
value, _fragment = urldefrag(value)
parts = urlsplit(value)
if parts.scheme not in {"http", "https"} or not parts.netloc:
return None
# Keep path and query; remove only the fragment for crawl identity.
return urlunsplit((parts.scheme.lower(), parts.netloc.lower(),
parts.path or "/", parts.query, ""))
def fetch_xml(url: str) -> bytes:
r = requests.get(url, timeout=45,
headers={"User-Agent": "URLDiscovery/1.0"})
r.raise_for_status()
data = r.content
if url.lower().endswith(".gz") or r.headers.get("Content-Type", "").startswith("application/x-gzip"):
data = gzip.decompress(data)
return data
def discover(site_url: str) -> list[str]:
roots = sitemap_locations(site_url)
if not roots:
roots = [urljoin(site_url.rstrip("/") + "/", "sitemap.xml"),
urljoin(site_url.rstrip("/") + "/", "sitemap_index.xml")]
queue, seen_docs, found = deque(roots), set(), set()
while queue:
doc_url = queue.popleft()
if doc_url in seen_docs:
continue
seen_docs.add(doc_url)
try:
root = ET.fromstring(fetch_xml(doc_url))
except (requests.RequestException, ET.ParseError, OSError) as exc:
print(f"Skipping {doc_url}: {exc}")
continue
tag = root.tag.rsplit("}", 1)[-1].lower()
if tag == "sitemapindex":
for node in root.findall("sm:sitemap/sm:loc", NS):
child = clean_url(node.text or "", doc_url)
if child and child not in seen_docs:
queue.append(child)
elif tag == "urlset":
for node in root.findall("sm:url/sm:loc", NS):
target = clean_url(node.text or "", doc_url)
if target:
found.add(target)
else:
print(f"Ignoring unsupported root {tag} in {doc_url}")
return sorted(found)
for target in discover("https://example.com"):
print(target)
The queue prevents loops and the sets prevent duplicate documents and URLs. In production, persist progress so a temporary child-sitemap failure can be retried without starting over.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Limits, compression, and XML details
- Google documents a limit of 50 MB uncompressed or 50,000 URLs per sitemap.
- A sitemap index may list up to 50,000 sitemap locations.
- Large sites commonly split URL sets and use gzip compression. Check both the filename and the response
Content-Type; do not decompress ordinary XML twice. - Prefer fully qualified absolute URLs. Resolve relative values defensively, but record that the publisher supplied an unusual value.
lastmodcan help prioritize work when it is consistently accurate. Google says it ignorespriorityandchangefreq; do not build scheduling logic around them.
These are documented protocol/search guidance limits, not a promise that every server enforces them correctly. Reject oversized or deeply nested inputs safely and cap recursion and response sizes to protect your parser.
Normalize and validate candidate targets
Normalization decisions
- Remove fragments because browsers do not send them in HTTP requests.
- Lowercase the scheme and host, but preserve path and query semantics unless the target site documents a canonicalization rule.
- Deduplicate exact normalized strings. Decide separately whether tracking parameters such as
utm_*should be removed; that is a project policy, not a sitemap rule. - Keep a record of the original
locand the normalized value for auditing.
Validation pass
Use a bounded HEAD request only when the server supports it; otherwise make a small GET and stop reading after headers or a short byte limit. Record status, final URL, content type, and redirect chain. A 200 response still does not prove that the content is the page you want, while a 403, 429, timeout, or challenge requires a policy decision rather than aggressive retries.
Apply an explicit allowlist of hosts and schemes, a concurrency limit, exponential backoff for transient failures, and a durable checkpoint. Do not follow redirects to unrelated hosts without reviewing them. Never place credentials or sensitive query strings in logs.
Custom parser versus a crawler framework
| Concern | Custom parser | Crawler framework |
|---|---|---|
| Robots discovery | You implement fetching and policy handling. | Framework components can discover sitemap declarations from robots.txt. |
| Nested indexes | Recursive queue and cycle protection are yours to maintain. | Sitemap-aware spiders generally support nested sitemaps. |
| Filtering and output | Exact control over normalization, storage, and schemas. | Built-in scheduling, pipelines, retries, and exports. |
| Operational controls | You add throttling, retries, limits, and observability. | Use mature settings, but verify their current names and defaults. |
Scrapy’s documented SitemapSpider supports sitemap discovery, nested indexes, and robots.txt declarations, but the readily available reference is for release 0.24.6. Check the current Scrapy documentation before copying APIs or settings into a new project.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Troubleshooting
Robots.txt has no Sitemap line
Try the fallback filenames, inspect the site’s HTML or webmaster documentation, and stop if discovery is unsuccessful. Do not brute-force thousands of filenames.
XML parser reports no loc elements
Check the namespace and root type. Sitemaps can use a default namespace, so query with the namespace URI shown above.
Child sitemap returns HTML
It may be a login page, bot challenge, error document, or proxy response. Check status and Content-Type, save a bounded diagnostic sample, and do not feed arbitrary HTML to the XML parser.
Compressed sitemap fails
Inspect magic bytes and response headers, then decompress once. Some servers label gzip incorrectly; handle that case only with a safe size limit.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Too many duplicates
Normalize fragments, host casing, default ports, and redirect targets consistently. Keep query parameters unless you have a documented reason to discard them.
Requests are blocked or throttled
Reduce concurrency, honor Retry-After, add backoff, and review the site’s rules. A sitemap does not override access controls.
Or skip the browser setup
If your next step is to render pages rather than merely extract URLs, ScreenshotNeo provides a one-request screenshot API. It accepts consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; bot checks, blank pages, timeouts, failed loads, and cache hits are not billed. The response identifies the page verdict and billing with X-Page-Verdict and X-Billed headers. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients.
See the ScreenshotNeo API documentation for authentication and options.
cURL
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
Node.js
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
It includes full-page and element captures, device presets, dark mode, custom CSS and JavaScript, waits, blocking rules, cookies and headers, PDFs, caching, signed links, asynchronous webhooks, bulk capture of up to 100 URLs per call, and a usage API. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Cost, performance, and reliability planning
- Parse sitemap XML once and cache it with a timestamp; refetch according to the site’s publishing cadence.
- Use streaming or bounded downloads for untrusted files, and enforce maximum compressed and uncompressed sizes.
- Separate discovery from page crawling so a failed page request does not lose the URL inventory.
- Store source sitemap, discovery time, HTTP metadata, normalized URL, and validation result.
- For recurring jobs, compare URL sets to identify additions and removals instead of recrawling everything.
- Measure request rate and error classes, not just total URLs. A fast run that triggers blocking is not reliable.
FAQ
Does every website have a sitemap?
No. A site may omit one, publish it under an unadvertised path, or expose only part of its URL inventory.
Can I assume sitemap URLs are canonical?
No. Validate redirects and canonical signals during your later page-processing stage.
Should I crawl every URL immediately?
No. Treat the list as candidates, apply scope and authorization checks, then schedule controlled validation and crawling.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteQuick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

