Browse Source

Update sitemap for Python3

Fix sitemap code to work under Python3.

Change-Id: I7aad21f612047ce264b93460f7604b63fa951cab
changes/94/714594/1
Andreas Jaeger 4 months ago
parent
commit
b8a0df92b5
2 changed files with 2 additions and 2 deletions
  1. +1
    -1
      sitemap/generator/pipelines.py
  2. +1
    -1
      sitemap/generator/spiders/sitemap_file.py

+ 1
- 1
sitemap/generator/pipelines.py View File

@@ -83,7 +83,7 @@ class ExportSitemap(object):
% spider.domain))
with open(os.path.join(os.getcwd(), "sitemap_%s.xml" % spider.domain),
'w') as pretty:
pretty.write(lxml.etree.tostring(tree, pretty_print=True))
pretty.write(lxml.etree.tostring(tree, pretty_print=True, encoding='unicode'))

def process_item(self, item, spider):
self.exporter.export_item(item)


+ 1
- 1
sitemap/generator/spiders/sitemap_file.py View File

@@ -110,6 +110,6 @@ class SitemapSpider(spiders.CrawlSpider):
timestamp = response.headers['Last-Modified']
else:
timestamp = response.headers['Date']
lastmod = time.strptime(timestamp, "%a, %d %b %Y %H:%M:%S %Z")
lastmod = time.strptime(timestamp.decode("utf-8"), "%a, %d %b %Y %H:%M:%S %Z")
item['lastmod'] = time.strftime("%Y-%m-%dT%H:%M:%S%z", lastmod)
return item

Loading…
Cancel
Save