Skip to main content

Script/Library to read and parse sitemap.xml data

Project description

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_sitem ap.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.getSitemaps() # returns generator of sitemapper.Sitemap instances
else:
    urls = sm.getUrls()         # returns generator 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.1.10.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

site_map_parser-0.1.10-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: site-map-parser-0.1.10.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5

File hashes

Hashes for site-map-parser-0.1.10.tar.gz
Algorithm Hash digest
SHA256 1ee2b6e69cb32bd922c81811e93a6ea5ad951a367fcf084b025883e7b1006a9d
MD5 c0b307f0609ae46ea972373c79fbb92b
BLAKE2b-256 30b1a129b9b1704fcacd6527b1473881957aa2d0940ebc5bc1130df637966961

See more details on using hashes here.

File details

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

File metadata

  • Download URL: site_map_parser-0.1.10-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5

File hashes

Hashes for site_map_parser-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 1d039d03364facc07cac09bc163ed2ab800c4c8220fc49e31dab5208be102988
MD5 047ec307733ce60775d789c73f89a5ab
BLAKE2b-256 eb78f075f681e423d96b106f8a4b03d78dcf27da58b1a85003c3e134bf0b4cd8

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