Last Updated: 20-August-2015
I have had parse a number of XML sitemaps this week for different reasons so I thought I would make it a little easier and quicker. There are specific standard libraries for parsing XML but this is what I came up with...
from bs4 import BeautifulSoup
url = "http://www.site.co.uk/sitemap.xml"
r = requests.get(url)
data = r.text
soup = BeautifulSoup(data)
for url in soup.findAll("loc"):
About the author
Craig Addyman @craigaddyman
Head of Digital Marketing. Python Coder.