mirror of
https://github.com/scrapy/scrapy.git
synced 2025-02-23 21:44:19 +00:00
renamed to sitemap_alternate_links and added default value, see #360
This commit is contained in:
parent
8ed2d0cda1
commit
6994959181
@ -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
|
||||
|
@ -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':
|
||||
|
Loading…
x
Reference in New Issue
Block a user