Ver código fonte

Update sitemap for Python3

Fix sitemap code to work under Python3.

Change-Id: I7aad21f612047ce264b93460f7604b63fa951cab
changes/94/714594/2
Andreas Jaeger 1 semana atrás
pai
commit
b9d280acce
2 arquivos alterados com 4 adições e 2 exclusões
  1. +2
    -1
      sitemap/generator/pipelines.py
  2. +2
    -1
      sitemap/generator/spiders/sitemap_file.py

+ 2
- 1
sitemap/generator/pipelines.py Ver arquivo

@@ -83,7 +83,8 @@ 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)


+ 2
- 1
sitemap/generator/spiders/sitemap_file.py Ver arquivo

@@ -110,6 +110,7 @@ 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

Carregando…
Cancelar
Salvar