Created
April 15, 2024 12:15
-
-
Save eliasdabbas/0472b5f6cb3926305a71637f80120873 to your computer and use it in GitHub Desktop.
Convert a list of URLs to an XML sitemap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import pandas as pd | |
lastmod = datetime.datetime.now(datetime.UTC).strftime('%Y-%m-%d') | |
url_list = [ | |
'https://nbastats.pro/player/Eric_Moreland', | |
'https://nbastats.pro/player/Marc_Iavaroni', | |
'https://nbastats.pro/player/Keith_Tower', | |
'https://nbastats.pro/player/Hakeem_Olajuwon', | |
'https://nbastats.pro/player/Mike_Price', | |
'https://nbastats.pro/player/Doug_Collins', | |
] | |
print((pd.DataFrame({ | |
'loc': url_list, | |
'lastmod': lastmod}) | |
.to_xml( | |
index=False, | |
root_name='urlset', | |
row_name='url', | |
namespaces={"": "http://www.sitemaps.org/schemas/sitemap/0.9"} | |
))) |
Author
eliasdabbas
commented
Apr 15, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment