linklerinizi linkler.txt dosyasına alt alta yapiştirip kodu çalıştırın sitemp.xml olarak kaydedecektir.

def create_sitemap(links):
    sitemap_template = '''<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{urls}
</urlset>'''

    url_template = '''<url>
  <loc>{url}</loc>
</url>'''

    urls = "\n".join([url_template.format(url=link.strip()) for link in links])

    sitemap = sitemap_template.format(urls=urls)
    return sitemap

def main():
    input_file = "linkler.txt"
    output_file = "sitemap.xml"

    try:
        with open(input_file, "r") as f:
            links = f.readlines()
        
        sitemap_content = create_sitemap(links)

        with open(output_file, "w") as f:
            f.write(sitemap_content)

        print(f"Sitemap oluşturuldu: {output_file}")
    
    except FileNotFoundError:
        print(f"{input_file} dosyası bulunamadı.")
    except Exception as e:
        print(f"Bir hata oluştu: {e}")

if __name__ == "__main__":
    main()