31 lines
709 B
Python
31 lines
709 B
Python
from ipaddress import ip_address
|
|
from whois import whois
|
|
from ipwhois import IPWhois
|
|
import validators
|
|
from constants import URL, DOMAIN, IPV4, IPV6
|
|
|
|
|
|
def check(host):
|
|
if validators.url(host):
|
|
host_type = URL
|
|
elif validators.domain(host):
|
|
host_type = DOMAIN
|
|
elif validators.ip_address.ipv4(host):
|
|
host_type = IPV4
|
|
elif validators.ip_address.ipv6(host):
|
|
host_type = IPV6
|
|
return host_type
|
|
|
|
|
|
# def lookup(host_type):
|
|
def lookup(host):
|
|
result = dict(whois(host))
|
|
return result
|
|
|
|
|
|
# result = whois(host_type[1])
|
|
# return result, host_type[0]
|
|
# obj = IPWhois(host_type[1])
|
|
# res = obj.lookup_rdap()
|
|
# return res, host_type[0]
|