Checking whether a host has a second-level domain from a list I have an url and need to check whether it has some second-level domain (SLD) from a list. For example for SLD foo.com I need to approve hosts foo.com, some.foo.com and reject host kungfoo.com. There is some solution:

domains_a = ['foo.com', 'bar.com', 'fur.net', 'beer.org']
domains_dot_a = ['.foo.com', '.bar.com', '.fur.net', '.beer.org']

domains_b = ['door.com', ... ]
domains_dot_b = ['.door.com', ... ]

domains_c = ['doom.com', ... ]
domains_dot_c = ['.doom.com', ... ]

def any_sld_matches(domains, domains_dot, host):
    return (host in domains) or any(host.endswith(sld) for sld in domains_dot)

def get_url_category(url):
    host = urlparse.urlparse(url.strip()).netloc
    if any_sld_matches(domains_a, domains_dot_a, host):
        return 'a'
    elif any_sld_matches(domains_b, domains_dot_b, host):
        return 'b'
    elif any_sld_matches(domains_c, domains_dot_c, host):
        return 'c'
    elif not host:
        return 'empty'
    else:
        return None
You can change your function to be much faster if you use a set.
You can also use re to reduce the amount of code too.

The regex that you can use is an optional non-capturing group of anything ending with a  ..
And a capturing group at the end of the string with one period:

(?=.+\.)?([^\.]+\.[^\.]+)$


Using this you can lop off the second-level domain, and do a single check.

def get_url_category(url):
    host = urlparse.urlparse(url.strip()).netloc
    domain = re.search(r'(?=.+\.)?([^\.]+\.[^\.]+)$', host)
    if domain is not None:
        domain = domain.group(1)
        if domain in domains_a:
            return 'a'
    if not host:
        return 'empty'
    return None


To make this faster you should change domains_a to a set:

domains_a = {'foo.com', 'bar.com', 'fur.net', 'beer.org'}


And finally to make the program easier to write you can change the domains to be a dictionary of sets.
To use this just loop through the items via domains.iteritems().
And if the host is found then you return the group.

domains = {
    'a': {'foo.com', 'bar.com', 'fur.net', 'beer.org'},
    'b': {'door.com', ...},
    'c': {'doom.com', ...}
}

def get_url_category(url):
    host = urlparse.urlparse(url.strip()).netloc
    domain = re.search(r'(?=.+\.)?([^\.]+\.[^\.]+)$', host)
    if domain is not None:
        domain = domain.group(1)
        for group, domains_ in domains.iteritems():
            if domain in domains_:
                return group
    if not host:
        return 'empty'
    return None


Finally I think returning None is a bit strange, but is fine.