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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 2 Python 3

File details

Details for the file sitemap_python-0.2.0.tar.gz.

File metadata

File hashes

Hashes for sitemap_python-0.2.0.tar.gz
Algorithm Hash digest
SHA256 602e744f2cf8606ed09ba38a490bfa3c94826c15bc90215f7ac0c102c350bc2b
MD5 f7d99b5ebf41011f2e301011abe39a0f
BLAKE2b-256 d0d636afef82a9102cf11e50b3d239bb599321d642edd5630f2cbfdf9ff32219

See more details on using hashes here.

File details

Details for the file sitemap_python-0.2.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for sitemap_python-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 280b7a2bb0d8ebb3335abba9ec3b63c1183f050a4e62943a1a465e7c7cc100d3
MD5 de81635c4e95ca9438a4ba81371c858a
BLAKE2b-256 1ecaaa7d28283b83976405df2a31557ce7aa7cc701621d05757a10f25f815881

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