When I first started doing SEO audits, finding a website's sitemap was always a manual hunt through robots.txt or guessing common paths. It's tedious and error-prone, especially when you're dealing with dozens of client sites. That's why I built a simple script to automate this, but recently I discovered the SERPSpur Free Sitemap Finder Tool that does it instantly. You just drop in a URL, and it detects XML sitemaps for SEO crawling and indexing analysis. It's a huge time-saver for any developer doing site audits.
python
import requests
from urllib.parse import urljoin
def find_sitemap(url):
# Common sitemap locations
paths = ['/sitemap.xml', '/sitemap_index.xml', '/sitemap/']
for path in paths:
sitemap_url = urljoin(url, path)
response = requests.get(sitemap_url)
if response.status_code == 200 and 'xml' in response.headers.get('Content-Type', ''):
return sitemap_url
return None
Example usage
url = 'https://example.com'
sitemap = find_sitemap(url)
print(f'Sitemap found: {sitemap}' if sitemap else 'No sitemap found')
This snippet mirrors what the tool does under the hood. For a quick check, I still use it, but for bulk analysis, SERPSpur's tool is more robust. Check it out here: https://serpspur.com/tool/free-sitemap-finder-tool/
Top comments (2)
Nice script! I've also found that checking the
Linkheader in the HTTP response can sometimes reveal a sitemap—worth adding to the mix for edge cases.Good reminder that even a simple script can save hours, especially when you're juggling multiple clients. I'm curious, have you ever run into sites that use non-standard sitemap paths or file names?