Update sitemap for Python3
Fix sitemap code to work under Python3. Change-Id: I7aad21f612047ce264b93460f7604b63fa951cab
This commit is contained in:
parent
5888968ec0
commit
b9d280acce
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user