Scrapy, a fast high-level web crawling & scraping framework for Python.
Only follow alternate sitemap links (#8390)
ethancyyiu53998e2b6567
diff --git a/scrapy/utils/_sitemap.py b/scrapy/utils/_sitemap.pyindex 2edf2d5ef..2a00ddf37 100644--- a/scrapy/utils/_sitemap.py+++ b/scrapy/utils/_sitemap.py@@ -66,7 +66,7 @@ class Sitemap:continueif tag_name == "link":- if href := el.get("href"):+ if el.get("rel") == "alternate" and (href := el.get("href")):alternate.append(href)else:d[tag_name] = el.text.strip() if el.text else ""diff --git a/tests/test_spider_sitemap.py b/tests/test_spider_sitemap.pyindex ca5eb0985..965543490 100644--- a/tests/test_spider_sitemap.py+++ b/tests/test_spider_sitemap.py@@ -257,6 +257,8 @@ Sitemap: /sitemap-relative-url.xmlxmlns:xhtml="http://www.w3.org/1999/xhtml"><url><loc>http://www.example.com/english/</loc>+ <xhtml:link rel="canonical"+ href="http://www.example.com/canonical/"/><xhtml:link rel="alternate" hreflang="de"href="http://www.example.com/deutsch/"/><xhtml:link rel="alternate" hreflang="de-ch"