Sitemap library for dynamically generating sitemap.xml
pip install sitemap
from sitemap import Url, Urlset
urlset = Urlset()
url = Url('https://www.example.com/', changefreq='weekly')
urlset.add_url(url)
# urlset.to_string()
urlset.write_xml('sitemap.xml')
from sitemap import Sitemap, Siteindex
siteindex = Siteindex()
sitemap = Sitemap('https://www.example.com/sitemap.xml')
siteindex.add_sitemap(sitemap)
# siteindex.to_string()
siteindex.write_xml('sitemap.xml')