Python’s get_tld works very well but is slow if you’re looking up a batch of domain names. Here’s a faster version that falls back on get_tld: