Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

renamed to sitemap_alternate_links and added default value, see #360

Stefan699495918194
diff --git a/docs/topics/spiders.rst b/docs/topics/spiders.rst
index e9afe1368..82e96df1e 100644
--- a/docs/topics/spiders.rst
+++ b/docs/topics/spiders.rst
@@ -560,7 +560,7 @@ SitemapSpider
By default, all sitemaps are followed.
- .. attribute:: use_alternate_links
+ .. attribute:: sitemap_alternate_links
Specifies if alternate links for one ``url`` should be followed. These
are links for the same website in another language passed within
@@ -573,11 +573,11 @@ SitemapSpider
<xhtml:link rel="alternate" hreflang="de" href="http://example.com/de"/>
</url>
- With ``use_alternate_links`` set, this would retrieve both URLs. With
- ``use_alternate_links`` disabled, only ``http://example.com/`` would be
+ With ``sitemap_alternate_links`` set, this would retrieve both URLs. With
+ ``sitemap_alternate_links`` disabled, only ``http://example.com/`` would be
retrieved.
- Default is ``use_alternate_links`` disabled.
+ Default is ``sitemap_alternate_links`` disabled.
SitemapSpider examples
diff --git a/scrapy/contrib/spiders/sitemap.py b/scrapy/contrib/spiders/sitemap.py
index eb14b614d..d8567f7f0 100644
--- a/scrapy/contrib/spiders/sitemap.py
+++ b/scrapy/contrib/spiders/sitemap.py
@@ -11,6 +11,7 @@ class SitemapSpider(BaseSpider):
sitemap_urls = ()
sitemap_rules = [('', 'parse')]
sitemap_follow = ['']
+ sitemap_alternate_links = False
def __init__(self, *a, **kw):
super(SitemapSpider, self).__init__(*a, **kw)
@@ -37,7 +38,7 @@ class SitemapSpider(BaseSpider):
s = Sitemap(body)
if s.type == 'sitemapindex':
- for loc in iterloc(s, self.use_alternate_links):
+ for loc in iterloc(s, self.sitemap_alternate_links):
if any(x.search(loc) for x in self._follow):
yield Request(loc, callback=self._parse_sitemap)
elif s.type == 'urlset':