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: https://www.sitemaps.org/protocol.html

Installation

pip install site-map-parser

Usage

Script usage

smapper $url > /tmp/data.csv

Logs written to ~/sitemap_run.log

Arguments

Argument Options Default Information
-h N/A N/A Outputs argument data
url e.g. http://www.example.com - http://www.example.com/other_sitemap.xml 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('http://www.example.com')    # reads /sitemap.xml
if sm.has_sitemaps():
    sitemaps = sm.get_sitemaps() # returns iterator of sitemapper.Sitemap instances
else:
    urls = sm.get_urls()         # returns iterator of sitemapper.Url instances

Exporting

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():
    print(csv_exporter.export_sitemaps())
elif sm.has_urls():
    print(csv_exporter.export_urls())
JSON Exporter
from sitemapparser.exporters import JSONExporter

# sm set as per earlier library usage example

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

Project details


Download files

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

Source Distribution

site-map-parser-0.3.8.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

site_map_parser-0.3.8-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file site-map-parser-0.3.8.tar.gz.

File metadata

  • Download URL: site-map-parser-0.3.8.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.9

File hashes

Hashes for site-map-parser-0.3.8.tar.gz
Algorithm Hash digest
SHA256 578010b1a32fb107edac199cb5f97a4199ff6b59145033140fa7b46ab5036d8b
MD5 677d95d91b8aeda46eba3b5827e69578
BLAKE2b-256 73dc957923f5e753b2153ba2e677ff367a23fbd6de2b76a4490e49cf50c8ab4c

See more details on using hashes here.

File details

Details for the file site_map_parser-0.3.8-py3-none-any.whl.

File metadata

  • Download URL: site_map_parser-0.3.8-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.9

File hashes

Hashes for site_map_parser-0.3.8-py3-none-any.whl
Algorithm Hash digest
SHA256 9282166240d036df136824abea526d73f64abed7d7508b65ca5005b78fa326b6
MD5 a46243bd3701f52317623b0f53dce05a
BLAKE2b-256 2c0013124b737df4c685845d720f8d93d5ee23dfc26483b0aa47a522f892facf

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page