def url_is_from_any_domain(url, domains):
    """Return True if the url belongs to any of the given domains"""
    host = parse_url(url).netloc.lower()
    if not host:
        return False
    domains = [d.lower() for d in domains]
    return any((host == d) or (host.endswith('.%s' % d)) for d in domains)
Return True if the url belongs to any of the given domains
stackoverflow/venv/lib/python3.6/site-packages/scrapy/utils/url.py