Skip to content

Instantly share code, notes, and snippets.

@azat
Last active July 22, 2022 12:29
Show Gist options
  • Save azat/c1a7a9f1e3519793134ef4b1df5461a6 to your computer and use it in GitHub Desktop.
Save azat/c1a7a9f1e3519793134ef4b1df5461a6 to your computer and use it in GitHub Desktop.
import publicsuffix2
import clickhouse_driver
ch = clickhouse_driver.Client(host='127.1')
pls = publicsuffix2.PublicSuffixList(idna=False)
def check_tld(tld):
print(tld)
host = 'foo.' + tld
ch_tld = ch.execute("SELECT cutToFirstSignificantSubdomainCustom(%(host)s, 'public_suffix_list')", params={
'host': host,
})[0][0].strip()
py_tld = pls.get_public_suffix(host)
assert ch_tld == py_tld, f'ch_tld={ch_tld}, py_tld={py_tld}, host={host}'
tlds = pls.tlds
any(map(check_tld, tlds))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment