INNER CODE UNIT · Python

generate_sitemaps_xml_gz

netkiller/netkiller.github.io · generate_sitemaps.py:83

def generate_sitemaps_xml_gz(html_files):
    """Generate sitemaps.xml.gz (compressed version)."""
    lines = ['<?xml version="1.0" encoding="UTF-8"?>']
    lines.append('<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">')
    
    for rel_path in html_files:
        full_path = OUTPUT_DIR / rel_path
        lastmod = get_lastmod(full_path)
        url_path = url_encode_path(rel_path)
        
        lines.append('  <url>')
        lines.append(f'    <loc>{BASE_URL}/{url_path}</loc>')
        lines.append(f'    <lastmod>{lastmod}</lastmod>')
        lines.append('  </url>')
    
    lines.append('</urlset>')
    
    with gzip.open(OUTPUT_DIR / 'sitemaps.xml.gz', 'wt', encoding='utf-8') as f:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…