# Python code to create an XML sitemap. # See http://www.sitemaps.org/protocol.php # Place in same directory as your content and pipe output to a file. # Assumes all content to index is in one directory. # Written by John D. Cook, http://www.johndcook.com import os, time # your base URL url = "http://www.johndcook.com/" # file types to include in sitemap extensions_to_keep = ['.htm', '.html', '.pdf'] print '' print '' for file in os.listdir("."): # exclude proof-of-ownership files if file.startswith( ("google", "y_key_") ): continue file_extension = os.path.splitext(file)[1] if file_extension in extensions_to_keep: file_mod_time = time.gmtime(os.path.getmtime(file)) utc = time.strftime("%Y-%m-%dT%H:%M:%SZ", file_mod_time) print " " print " %s%s" % (url, file) print " %s" % utc print " " print ""