def get_host_regex(self, spider):
        allowed_domains = getattr(spider, 'allowed_domains', None)
        if not allowed_domains:
            return re.compile('') # allow all by default
        regex = r'^(.*\.)?(%s)$' % '|'.join(re.escape(d) for d in allowed_domains if d is not None)
        return re.compile(regex)
Override this method to implement a different offsite policy
dataset/ETHPy150Open scrapy/scrapy/scrapy/spidermiddlewares/offsite.py/OffsiteMiddleware.get_host_regex