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 →To extract URLs from a sitemap, fetch its XML, parse the standard sitemap namespace, and read each <loc> value. If the root element is <sitemapindex>, fetch each child sitemap and repeat the process. The Python example below handles both sitemap files and indexes, checks HTTP errors, and prevents revisiting the same sitemap.
What to extract from a sitemap
A standard sitemap is XML. Its root is usually <urlset>, containing <url> entries with a required <loc> URL. Optional elements can include <lastmod>, <changefreq>, and <priority>. A sitemap index instead has a <sitemapindex> root and lists other sitemap files in <sitemap><loc> entries.
The Sitemap protocol format consists of XML tags, according to sitemaps.org’s protocol documentation. Use fully qualified absolute URLs and respect the host and protocol scope allowed for the sitemap’s location. Google’s documentation sets a per-file limit of 50 MB uncompressed or 50,000 URLs; split larger collections across files and use an index to point to them. See Google Search Central’s large sitemap guidance.
Extracting a URL from a sitemap does not establish that the page is indexed, reachable, or eligible for search results. Treat <lastmod> as update metadata only when your workflow needs it, not as proof of indexing.
#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.
Extract URLs and follow a sitemap index with Python
Install the dependencies with python -m pip install requests lxml. Save the following as extract_sitemap.py. Pass the URL of a sitemap or sitemap index as the first command-line argument.
import sys
from urllib.parse import urlparse
import requests
from lxml import etree
NS = {"sm": "http://www.sitemaps.org/schemas/sitemap/0.9"}
TIMEOUT = 30
MAX_DEPTH = 10
MAX_SITEMAPS = 1000
def fetch_root(url):
response = requests.get(url, timeout=TIMEOUT)
response.raise_for_status()
# Do not enable DTD loading or entity resolution for untrusted XML.
parser = etree.XMLParser(resolve_entities=False, load_dtd=False, no_network=True)
return etree.fromstring(response.content, parser=parser)
def extract_urls(sitemap_url, visited=None, depth=0):
if visited is None:
visited = set()
if depth > MAX_DEPTH:
raise ValueError(f"Maximum sitemap depth ({MAX_DEPTH}) exceeded")
if sitemap_url in visited:
return []
if len(visited) >= MAX_SITEMAPS:
raise ValueError(f"Maximum sitemap count ({MAX_SITEMAPS}) exceeded")
visited.add(sitemap_url)
root = fetch_root(sitemap_url)
root_name = etree.QName(root).localname
if root_name == "sitemapindex":
child_urls = root.xpath("/sm:sitemapindex/sm:sitemap/sm:loc/text()", namespaces=NS)
results = []
for child in child_urls:
child = child.strip()
if child:
results.extend(extract_urls(child, visited, depth + 1))
return results
if root_name != "urlset":
raise ValueError(f"Unexpected sitemap root element: {root_name}")
return [value.strip() for value in root.xpath(
"/sm:urlset/sm:url/sm:loc/text()", namespaces=NS
) if value.strip()]
if __name__ == "__main__":
sitemap_url = sys.argv[1]
parsed = urlparse(sitemap_url)
if parsed.scheme not in ("http", "https") or not parsed.netloc:
raise SystemExit("Provide an absolute http:// or https:// sitemap URL")
for page_url in extract_urls(sitemap_url):
print(page_url)
Run it like this:
python extract_sitemap.py https://example.com/sitemap.xml
The XPath expressions include the standard sitemap namespace explicitly. That matters because XML parsers do not treat namespaced tags as unqualified names: a query for plain loc can return no matches even when the document contains many URLs. The code checks the HTTP response before parsing, trims surrounding whitespace, distinguishes an index from a URL set, and uses a visited set to avoid processing the same sitemap repeatedly.
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.
Preserve update metadata when needed
If your task also needs lastmod, select the <url> entries and read both fields from each entry rather than collecting separate lists that could lose their pairing. For example, replace the final return expression with:
return [
{
"url": (entry.findtext("sm:loc", namespaces=NS) or "").strip(),
"lastmod": (entry.findtext("sm:lastmod", namespaces=NS) or "").strip() or None,
}
for entry in root.xpath("/sm:urlset/sm:url", namespaces=NS)
]
Do not retain optional fields you have no use for; they do not change the extracted page URL.
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.
Make extraction safer and more useful
- Validate URLs and scope. Check that extracted values are absolute URLs and, where your application requires it, belong to the expected host and protocol. Do not assume every child URL in an index is safe to fetch merely because it appeared in a document.
- Set resource budgets. The example caps recursion depth and the number of distinct sitemap files. Tune those limits to your use case, and add a total URL cap if the downstream process cannot accept an unbounded result.
- Handle duplicate page URLs deliberately. If duplicates should be removed, preserve order with
list(dict.fromkeys(urls)). Avoid normalizing paths, query strings, trailing slashes, or percent-encoding unless your application has an explicit canonicalization policy. - Support compressed files when required. Some sources publish
.xml.gzsitemaps. Requests typically handles HTTP content encoding, but a gzip file served as a gzip archive may need explicit decompression before XML parsing. Detect and decompress the gzip payload with Python’sgzipmodule, then parse the decompressed bytes. Enforce a decompressed-size limit to avoid excessive memory use. - Stream or split large output. The example returns a list in memory. For large collections, write each result as it is discovered or process batches so the full URL set need not remain in memory. Keep the protocol’s per-file 50 MB uncompressed and 50,000-URL limits in mind when validating sitemap files.
- Disable unsafe XML features. The parser configuration in the example disables entity resolution, DTD loading, and network access. Keep equivalent protections enabled if you use a different XML library.
Other ways to extract sitemap URLs
Scrapy
For a crawling project already built with Scrapy, its SitemapSpider accepts sitemap URLs and yields parsed entries. Scrapy removes namespaces from tags in its item representation, so its field handling differs from namespace-aware XPath in lxml. Use the approach that fits the rest of your crawler rather than introducing a second framework for a one-off extraction.
Hosted extraction API
A hosted service can avoid maintaining the fetch-and-parse code, but check index recursion, depth and URL caps, authentication, compression support, and export format before relying on it. SitemapKit documents an authenticated extraction endpoint, recursive index support up to depth 5, and a maxUrls parameter capped at 50,000: SitemapKit documentation. Those are documented service limits, not general sitemap protocol limits.
Rank #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
Generate or export from the source system
If you control the site and need a dependable recurring inventory, Google recommends extracting URLs from the site’s database or having the website software generate the sitemap. That can be more direct than downloading and parsing a public XML file. See Google Search Central’s sitemap creation guidance.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Troubleshooting common extraction problems
- The script returns an empty list. Check the root element and namespace. Standard sitemap tags use
http://www.sitemaps.org/schemas/sitemap/0.9; use the namespace-aware XPath shown above. Also confirm you are parsing aurlset, not expecting URLs directly from an index. - HTTP 403, 404, or 5xx response. The sitemap URL may be wrong, unavailable, access-controlled, or rejecting the request. Verify it in a browser or with an HTTP client, then use the correct public sitemap URL or request authorized access.
raise_for_status()surfaces these responses instead of quietly parsing an error page. - Timeout or connection error. The host may be slow or temporarily unreachable. A finite timeout prevents a request from hanging indefinitely. For production jobs, add bounded retries with backoff for transient network and server errors; do not retry malformed XML as though it were a network failure.
- XML parse error. Inspect the response body and content type: servers sometimes return an HTML challenge or error page at a sitemap URL. Also check whether the file is gzip-compressed and whether it is truncated or malformed.
- Only some URLs appear. The top-level document may be an index; recurse into every child sitemap. Check whether your own depth, file-count, or output caps stopped processing, and record those stopping conditions so partial output is not mistaken for a complete export.
- Repeated URLs or sitemaps. A sitemap can list duplicate entries, and indexes can point to repeated files. Deduplicate page URLs only if your use case permits it; use a visited set for sitemap files.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server for developers, not a sitemap URL extractor. If the next step is to inspect how pages render, one request can capture a URL as PNG, JPEG, WebP, or PDF. Its API also accepts common screenshot API parameter names to make switching easier. See ScreenshotNeo and the API documentation.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →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.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
Cookie banners are accepted and removed before capture, along with supported newsletter popups and chat widgets; those cleanup steps can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. An MCP server provides screenshot tools for AI agents, including Claude, Cursor, and other MCP clients. The free plan includes 1,000 shots a month with no card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
Frequently Asked Questions
Does extracting a sitemap URL mean the page is indexed by Google?
No. A sitemap is a URL discovery signal, not proof that a page is indexed.
Why does an XML sitemap parser need a namespace?
Sitemap elements are qualified by the standard sitemap namespace. A parser that searches only for unqualified tag names may find no <loc> entries.
Free tools Windows power users keep installed
One-click scans. No signup required.
Quick 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.

