From 574b070bb4574348c33a15b68de76030984c031d Mon Sep 17 00:00:00 2001 From: Pablo Hoffman Date: Fri, 8 Jul 2011 09:33:56 -0300 Subject: [PATCH] fixed minor bug in sitemap parser --- scrapy/tests/test_utils_sitemap.py | 8 +++++++- scrapy/utils/sitemap.py | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/scrapy/tests/test_utils_sitemap.py b/scrapy/tests/test_utils_sitemap.py index fc1f3b15f..331888753 100644 --- a/scrapy/tests/test_utils_sitemap.py +++ b/scrapy/tests/test_utils_sitemap.py @@ -51,10 +51,16 @@ class SitemapTest(unittest.TestCase): daily 1 + + http://www.example.com/2 + + """) self.assertEqual(list(s), - [{'priority': '1', 'loc': 'http://www.example.com/', 'lastmod': '2009-08-16', 'changefreq': 'daily'}]) + [{'priority': '1', 'loc': 'http://www.example.com/', 'lastmod': '2009-08-16', 'changefreq': 'daily'}, + {'loc': 'http://www.example.com/2', 'lastmod': ''}, + ]) def test_sitemap_urls_from_robots(self): robots = """User-agent: * diff --git a/scrapy/utils/sitemap.py b/scrapy/utils/sitemap.py index e8d3b367e..d0157d397 100644 --- a/scrapy/utils/sitemap.py +++ b/scrapy/utils/sitemap.py @@ -23,7 +23,7 @@ class Sitemap(object): d = {} for el in elem.getchildren(): _, name = el.tag.split('}', 1) - d[name] = el.text.strip() + d[name] = el.text.strip() if el.text else '' yield d def sitemap_urls_from_robots(robots_text):