Skip to content

Instantly share code, notes, and snippets.

@notsobad
Created June 23, 2013 10:54
Show Gist options
  • Save notsobad/5844603 to your computer and use it in GitHub Desktop.
Save notsobad/5844603 to your computer and use it in GitHub Desktop.
DOMAIN_SUFFIX = (
'.gov.cn',
'.com.cn',
'.edu.cn',
'.net.cn',
'.org.cn',
)
def get_root_domain(domain):
arr = line.strip().split('.')
for suf in DOMAIN_SUFFIX:
if domain.endswith(suf):
return '.'.join(arr[-3:])
return '.'.join(arr[-2:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment