from langconv import ConverterHandler import urllib def genLoc(filePath): c = open(filePath) conv = ConverterHandler('zh-hant') word = u'女装连衣裙' for x in xrange(100000): line = word if len(line): keyword = '' keyword = urllib.quote(conv.convert(line.strip()).encode('utf-8')) if not len(keyword): continue url = 'http://example.com/?q=%s' % keyword yield url site = SiteMap() for kw in genLoc('./sample.txt'): site.add( loc=kw, lastmod=datetime.now(), changefreq='weekly') feed = open('./sitemap.xml', 'w') feed.write(site.to_string()) feed.close()
#!/usr/bin/env python from pysitemap import SiteMap from datetime import datetime site = SiteMap(domain='http://example.com') site.add(loc='http://example.com/webhp', lastmod=datetime.now(), changefreq='weekly') print site.to_string()
#!/usr/bin/env python from pysitemap import SiteMap from datetime import datetime site = SiteMap(domain='http://example.com') site.add( loc='http://example.com/webhp', lastmod=datetime.now(), changefreq='weekly' ) print site.to_string() # Site with images image_site = SiteMap(domain='http://example.com') image_site.add( loc='http://example.com/webhp', lastmod=datetime.now(), changefreq='weekly', priority=0.8, 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()
#!/usr/bin/env python from pysitemap import SiteMap from datetime import datetime site = SiteMap(domain="http://example.com") site.add(loc="http://example.com/webhp", lastmod=datetime.now(), changefreq="weekly") print site.to_string()