Revert "Default values for OffsiteMiddleware"

This reverts commit ba29435138.
This commit is contained in:
Eugenio Lacuesta 2018-07-15 16:47:55 -03:00
parent cff9e87625
commit 60c2ef86f0
1 changed files with 3 additions and 7 deletions

View File

@ -19,9 +19,6 @@ class OffsiteMiddleware(object):
def __init__(self, stats):
self.stats = stats
# default values
self.host_regex = re.compile('') # allow all by default
self.domains_seen = set()
@classmethod
def from_crawler(cls, crawler):
@ -55,7 +52,7 @@ class OffsiteMiddleware(object):
"""Override this method to implement a different offsite policy"""
allowed_domains = getattr(spider, 'allowed_domains', None)
if not allowed_domains:
return
return re.compile('') # allow all by default
url_pattern = re.compile("^https?://.*$")
for domain in allowed_domains:
if url_pattern.match(domain):
@ -65,9 +62,8 @@ class OffsiteMiddleware(object):
return re.compile(regex)
def spider_opened(self, spider):
host_regex = self.get_host_regex(spider)
if host_regex:
self.host_regex = host_regex
self.host_regex = self.get_host_regex(spider)
self.domains_seen = set()
class URLWarning(Warning):