安装
pip install tld
获取
from tld import get_tld
get_tld("http://www.google.co.uk")
# 'co.uk'
get_tld("http://www.google.idontexist",fail_silently=True)
# None
判断
from tld import is_tld
is_tld('com)
# True
is_tld('uk')
# True
is_tld('ddd')
# False
is_tld('www.google.com')
# False
更多参考
github:https://github.com/barseghyanartur/tld/
ip库
安装
pip install IPy
使用
from IPy import IP
ipnet = IP('127.0.0.0/30')
ipv4 = IP('1.1.1.1')
ipv6 = IP('1080:0:0:0:8:800:200C:417A')
网友评论