A Python library for generating a sitemap
The latest version of this project (without the image or mobile extensions) can be found at http://github.com/vitalvas/pysitemap.
The latest version of my fork is available at https://github.com/midnightdev/pysitemap
To get the full extension, you need to download the source.
To install pysitemap without the image or video extensions, use pip.
- Option 1 : Install via pip ::
pip install pysitemap
- Option 2 : If you have downloaded the source ::
python setup.py install
from pysitemap import SiteMap
from datetime import datetime
site = SiteMap()
site.add(
loc='http://example.com/webhp',
lastmod=datetime.now(),
changefreq='weekly',
priority=0.5
)
print site.to_string()
from pysitemap import SiteMap
from datetime import datetime
image_site = SiteMap(domain='http://example.com')
image_site.add(
loc='http://example.com/webhp',
image_loc='http://example.com/webhp/my_image.png',
caption='This is a caption',
geo_location='London, England',
image_title='Awesome Image',
license='http://example.com/license.txt'
)
print image_site.to_string()
How to produce a Sitemap for a mobile site:
mobile_site = SiteMap(domain='http://m.example.com', mobile=True)
Please report the bugs at github issue tracker. https://github.com/vitalvas/pysitemap/issues
VitalVas source@vitalvas.com
Vitaliy Vasilenko
dblarons aaron.h.smith@vanderbilt.edu
Aaron Smith