Skip to main content

A Python utility for building sitemaps.

Usage

Generate sitemap

import datetime
import sitemap.generator as generator

sitemap = generator.Sitemap()
sitemap.add("http://www.example.com",
            lastmod=datetime.datetime.now(),
            changefreq="monthly",
            priority="1.0")
sitemap_xml = sitemap.generate()


sitemap_index = generator.Sitemap(type='sitemapindex')
sitemap_index.add("http://www.example.com/sitemap01.xml",
                  lastmod=datetime.datetime.now(),
sitemap_index_xml = sitemap_index.generate()

Ping search engine

Currently support ping Google and Bing with sitemap urls.

import sitemap.ping as ping

ping.ping("google", "http://www.example.com/sitemap.xml")
ping.ping_urls("bing", ["http://www.example.com/sitemap.xml"])

Push url to Baidu

Push urls directly to Baidu. Related document available at here.

import sitemap.baidu as baidu
bp = baidu.BaiduPush("http://www.example.com", "<YOUR_KEY>")
bp.add("http://www.example.com/example.html")
bp.flush()

Verify the spider ip address

sitemap.spider can be use to verify whether the ip address of spider is genius.

Example:

from sitemap.spider import get_verified_spider_name

# spider_name will be None if no search engine is matched
spider_name = get_verified_spider_name("66.249.65.219")

The method get_verified_spider_name has uses socket.gethostbyaddr, which may be slow in some cases. So make guess_spider_name_from_ua method may filter out several results via User-Agent.

from sitemap.spider import get_verified_spider_name, guess_spider_name_from_ua

spider_name = guess_spider_name_from_ua(spider_ua)
if spider_name:
    spider_name = get_verified_spider_name(spider_ip)

Metadata

Release files for sitemap_python 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sitemap_python 0.2.0
File Size Uploaded
sitemap_python-0.2.0.tar.gz 3.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sitemap_python 0.2.0
File Interpreter ABI Platform
sitemap_python-0.2.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 10.6 kB

Release files / sitemap_python-0.2.0.tar.gz

Download URL sitemap_python-0.2.0.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
602e744f2cf8606ed09ba38a490bfa3c94826c15bc90215f7ac0c102c350bc2b
BLAKE2b-256 checksum
How to use checksums
d0d636afef82a9102cf11e50b3d239bb599321d642edd5630f2cbfdf9ff32219
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / sitemap_python-0.2.0-py2.py3-none-any.whl

Download URL sitemap_python-0.2.0-py2.py3-none-any.whl
Size 6.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
280b7a2bb0d8ebb3335abba9ec3b63c1183f050a4e62943a1a465e7c7cc100d3
BLAKE2b-256 checksum
How to use checksums
1ecaaa7d28283b83976405df2a31557ce7aa7cc701621d05757a10f25f815881
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page