コード例 #1
0
ファイル: __init__.py プロジェクト: EntityReborn/SocBot
def whois(url):
    # clean domain to expose netloc
    domain = extract_domain(url)
    # call whois command with domain
    nic_client = NICClient()
    text = nic_client.whois_lookup(None, domain, 0)
    return WhoisEntry.load(domain, text)
コード例 #2
0
def whois(url):
    # clean domain to expose netloc
    domain = extract_domain(url)
    # call whois command with domain
    nic_client = NICClient()
    text = nic_client.whois_lookup(None, domain, 0)
    return WhoisEntry.load(domain, text)
コード例 #3
0
ファイル: __init__.py プロジェクト: relip/pywhois
def whois(url):
    # clean domain to expose netloc
    domain = extract_domain(url)
    try:
        # try native whois command first
        r = subprocess.Popen(['whois', "--no-redirect", domain], stdout=subprocess.PIPE)
        text = r.stdout.read()
    except OSError:
        # try experimental client
        nic_client = NICClient()
        text = nic_client.whois_lookup(None, domain, 0)
    return WhoisEntry.load(domain, text)
コード例 #4
0
def whois(url):
    # clean domain to expose netloc
    domain = extract_domain(url)
    try:
        # try native whois command first
        r = subprocess.Popen(['whois', domain], stdout=subprocess.PIPE)
        text = r.stdout.read()
    except OSError:
        # try experimental client
        nic_client = NICClient()
        text = nic_client.whois_lookup(None, domain, 0)
    return WhoisEntry.load(domain, text)
コード例 #5
0
ファイル: __init__.py プロジェクト: fgeek/pywhois
def whois(url):
    # clean domain to expose netloc
    ip_match = re.match(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$", url)
    if ip_match:
        domain = url
    else:
        domain = extract_domain(url)
    try:
        # try native whois command first
        r = subprocess.Popen(['whois', domain], stdout=subprocess.PIPE)
        text = r.stdout.read()
    except OSError:
        # try experimental client
        nic_client = NICClient()
        text = nic_client.whois_lookup(None, domain, 0)
    return WhoisEntry.load(domain, text)
コード例 #6
0
def get_data_from_host(host):
    flags = 0
    nic_client = NICClient()
    
    data = nic_client.whois_lookup(None, host, flags)
    w = WhoisEntry.load(host, data)
    
    keys_to_test = ['domain_name', 'expiration_date', 'updated_date', 'creation_date', 'status']
    
    results = {}
    for key in keys_to_test:
        results[key] = w.__getattr__(key)
        
    print repr(get_ips_for_host(host))
    
    for key in keys_to_test:
        print "%s: %s" % (key, results[key])  
コード例 #7
0
ファイル: __init__.py プロジェクト: hxp2k6/Katana
def whois(url, experimental=False):
    # clean domain to expose netloc
    ip_match = re.match(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$", url)
    if ip_match:
        domain = url
    else:
        domain = extract_domain(url)
    if not experimental:
        try:
            # try native whois command first
            r = subprocess.Popen(['whois', domain], stdout=subprocess.PIPE)
            text = r.stdout.read()
        except OSError:
            # try experimental client
            nic_client = NICClient()
            text = nic_client.whois_lookup(None, domain, 0)
    else:
        nic_client = NICClient()
        text = nic_client.whois_lookup(None, domain, 0)
    return WhoisEntry.load(domain, text)
コード例 #8
0
def query(domain, raw=False, recursive=True, query_server=None):
    top, domain = get_top_domain(domain)
    if query_server is None:
        if top in servers:
            query_server = servers[top]
        else:
            query_server = query_whois_server(domain)
            if query_server:
                servers[top] = query_server

    if query_server is None:
        print('*.{} is not supported!'.format(top))
        return '*.{} is not supported!'.format(top)

    print('query ' + domain)
    print('querying on ' + query_server + ' ...')

    response = None
    if redis_cli:
        response = redis_cli.get(domain)
        if response:
            response = str(response, 'utf-8')
    if response is None:
        response = send_resquest(query_server, 43, domain + '\r\n')
        if redis_cli:
            redis_cli.set(domain, bytes(response, 'utf-8'))
    whois_entry = WhoisEntry.load(domain, response)
    whois_entry['query_from'] = query_server

    if raw:
        result = response
    else:
        result = json.dumps(whois_entry,
                            ensure_ascii=False,
                            default=decode_datetime)

    if not recursive:
        return result

    if whois_entry.get('whois_server',
                       None) is not None and recursive and whois_entry[
                           'whois_server'] != query_server:
        tmp = query(domain, True, False, whois_entry['whois_server'])
        whois_tmp = WhoisEntry.load(domain, tmp)
        whois_tmp['query_from'] = whois_entry['whois_server']
        if whois_tmp.get('domain_name', None) is None:
            print('parse whois data error.')
            return result
        else:
            if raw:
                return response
            else:
                return json.dumps(whois_tmp,
                                  ensure_ascii=False,
                                  default=decode_datetime)
    else:
        return result


# domain = 'www.hfut.ca.cn'
# print(get_top_domain(domain))
#
# domain = 'www.baidu.edu.cn'
# print(get_top_domain(domain))
#
# domain = '我爱你.中国'
# print(get_top_domain(domain))
コード例 #9
0
def parse_raw(domain, data):
    return json.dumps(WhoisEntry.load(domain, data),
                      ensure_ascii=False,
                      default=decode_datetime)
コード例 #10
0
ファイル: whois.py プロジェクト: 755/nwwhois
 def info(self):
     try:
         return WhoisEntry.load(self.domain, self._whois_text)
     except PywhoisError:
         raise WhoisException