Skip to main content

UNKNOWN

Project description

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)

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

sitemap_python-0.2.0.tar.gz (3.9 kB view hashes)

Uploaded Source

Built Distribution

sitemap_python-0.2.0-py2.py3-none-any.whl (6.7 kB view hashes)

Uploaded Python 2 Python 3

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