提交 22c68baf 编写于 作者: J Jana Cavojska

url_pattern is now being compiled before entering the loop

上级 454d5e57
......@@ -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
\ No newline at end of file
pass
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册