Skip to content

Instantly share code, notes, and snippets.

@hamletbatista
Created February 27, 2019 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hamletbatista/f6e410601f9bcc767296a856e96e9d27 to your computer and use it in GitHub Desktop.
Save hamletbatista/f6e410601f9bcc767296a856e96e9d27 to your computer and use it in GitHub Desktop.
from jinja2 import Template
sitemap_template="""<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{% for page in pages %}
<url>
<loc>{{page[0]|safe}}</loc>
<lastmod>{{page[1]}}</lastmod>
</url>
{% endfor %}
</urlset>"""
template=Template(sitemap_template)
xml_sitemap_output=template.render(pages=df.itertuples())
print(xml_sitemap_output[:500])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment