Created
June 23, 2013 10:54
-
-
Save notsobad/5844603 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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