Skip to content

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

strip URL extracted from selectors (as per html5 standard)

Mikhail Korobov71dd5d0bf9d0
diff --git a/scrapy/http/response/text.py b/scrapy/http/response/text.py
index 1718b1f3b..5bfd2debb 100644
--- a/scrapy/http/response/text.py
+++ b/scrapy/http/response/text.py
@@ -142,10 +142,9 @@ class TextResponse(Response):
if isinstance(url, Link):
url = url.url
elif isinstance(url, parsel.Selector):
- url = _url_from_selector(url)
+ url = _url_from_selector(url).strip()
elif isinstance(url, parsel.SelectorList):
- raise ValueError("Please pass either string")
-
+ raise ValueError("SelectorList is not supported")
encoding = self.encoding if encoding is None else encoding
url = self.urljoin(url)