Skip to content

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

improving hostname extraction

arijitchakraborty66ff34cf05f5
diff --git a/scrapy/http/cookies.py b/scrapy/http/cookies.py
index 6902d29e8..c137d5ad1 100644
--- a/scrapy/http/cookies.py
+++ b/scrapy/http/cookies.py
@@ -22,11 +22,7 @@ class CookieJar(object):
# the cookiejar implementation iterates through all domains
# instead we restrict to potential matches on the domain
- req_host = urlparse_cached(request).netloc
-
- # Strip port numbers from netloc, if present
- if ':' in req_host:
- req_host = req_host.split(':')[0]
+ req_host = urlparse_cached(request).hostname
if not IPV4_RE.search(req_host):
hosts = potential_domain_matches(req_host)