Skip to main content

Script/Library to read and parse sitemap.xml data

Project description

Site Map Parser

Script and library which reads urls and converts to objects, allows exporting as CSV or JSON.

Handle sitemaps according to:


pip install site-map-parser


Script usage

smapper $url > /tmp/data.csv

Logs written to ~/sitemap_run.log


Argument Options Default Information
-h N/A N/A Outputs argument data
url e.g. - N/A Required - sitemap data to retrieve
-l, --log CRITICAL or ERROR or WARNING or INFO or DEBUG INFO logs to sitemapper_run.log in install folder
-e, --exporter csv or json csv Export format of the data

Library Usage

from sitemapparser import SiteMapParser

sm = SiteMapParser('')    # reads /sitemap.xml
if sm.has_sitemaps():
    sitemaps = sm.get_sitemaps() # returns iterator of sitemapper.Sitemap instances
    urls = sm.get_urls()         # returns iterator of sitemapper.Url instances


Two exporters are available: csv and json

CSV Exporter
from sitemapparser.exporters import CSVExporter

# sm set as per earlier library usage example

csv_exporter = CSVExporter(sm)
if sm.has_sitemaps():
elif sm.has_urls():
JSON Exporter
from sitemapparser.exporters import JSONExporter

# sm set as per earlier library usage example

json_exporter = JSONExporter(sm)
if sm.has_sitemaps():
elif sm.has_urls():

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for site-map-parser, version 0.3.6
Filename, size File type Python version Upload date Hashes
Filename, size site_map_parser-0.3.6-py3-none-any.whl (11.2 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size site-map-parser-0.3.6.tar.gz (7.2 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page