url_pattern is now being compiled before entering the loop

This commit is contained in:
Jana Cavojska 2017-12-07 18:38:29 +01:00
parent 454d5e5733
commit 22c68baf99
1 changed files with 2 additions and 2 deletions

View File

@ -53,8 +53,8 @@ class OffsiteMiddleware(object):
allowed_domains = getattr(spider, 'allowed_domains', None)
if not allowed_domains:
return re.compile('') # allow all by default
url_pattern = re.compile("^https?://.*$")
for domain in allowed_domains:
url_pattern = re.compile("^https?://.*$")
if url_pattern.match(domain):
warnings.warn("allowed_domains accepts only domains, not URLs. Ignoring URL entry %s in allowed_domains." % domain, URLWarning)
@ -67,4 +67,4 @@ class OffsiteMiddleware(object):
class URLWarning(Warning):
pass
pass