Initial commit
This commit is contained in:
parent
44cd02b396
commit
11fbe99fcd
27
setup.py
Normal file
27
setup.py
Normal file
@ -0,0 +1,27 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from setuptools import setup, find_packages
|
||||
import sys, os
|
||||
|
||||
__version__ = '0.1'
|
||||
|
||||
setup(name='whois',
|
||||
version=__version__,
|
||||
description="",
|
||||
long_description="",
|
||||
classifiers=[],
|
||||
keywords='whois',
|
||||
author='Larry Kim',
|
||||
author_email='admin@relip.org',
|
||||
url='http://github.com/relip/python-whois',
|
||||
license='MIT',
|
||||
packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
|
||||
include_package_data=True,
|
||||
zip_safe=False,
|
||||
install_requires=[
|
||||
# -*- Extra requirements: -*-
|
||||
],
|
||||
entry_points="""
|
||||
# -*- Entry points: -*-
|
||||
""",
|
||||
)
|
||||
0
src/parse.py
Normal file
0
src/parse.py
Normal file
5
src/test.py
Normal file
5
src/test.py
Normal file
@ -0,0 +1,5 @@
|
||||
import os
|
||||
|
||||
whoisServers = {}
|
||||
execfile(os.path.join(os.path.dirname(os.path.realpath(__file__)), "whois-servers.conf"), {}, whoisServers)
|
||||
print whoisServers
|
||||
4
src/whois-servers.conf
Normal file
4
src/whois-servers.conf
Normal file
@ -0,0 +1,4 @@
|
||||
whoisServer = {
|
||||
"so": "whois.nic.so",
|
||||
"id": "whois.pandi.or.id",
|
||||
}
|
||||
4
src/whois-servers.conf.save
Normal file
4
src/whois-servers.conf.save
Normal file
@ -0,0 +1,4 @@
|
||||
whois = {
|
||||
"so": "whois.nic.so",
|
||||
"id": "whois.pandi.or.id",
|
||||
}
|
||||
41
src/whois.py
Normal file
41
src/whois.py
Normal file
@ -0,0 +1,41 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import os
|
||||
import socket
|
||||
|
||||
class Whois(object):
|
||||
def __init__(self, domain):
|
||||
self.domain = domain
|
||||
self.tld = self.domain.split(".")[-1]
|
||||
|
||||
self.whoisServers = {}
|
||||
f = open(os.path.join(os.path.dirname(os.path.realpath(__file__)), "whois-servers.conf"), "r")
|
||||
exec("self.whoisServers = %s"%(f.read()))
|
||||
|
||||
def chooseServer(self):
|
||||
if self.whoisServers.has_key(self.tld):
|
||||
return self.whoisServers[self.tld]
|
||||
else:
|
||||
return self.tld + ".whois-servers.net"
|
||||
|
||||
def run(self, redirect=True):
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
try:
|
||||
s.connect((self.whoisServer, 43))
|
||||
except:
|
||||
print "ERROR Could not connect to whois server %s"%(self.whoisServer)
|
||||
|
||||
s.send(self.domain + "\r\n")
|
||||
|
||||
result = ""
|
||||
|
||||
while True:
|
||||
buffer = s.recv(512)
|
||||
|
||||
if not buffer: break
|
||||
|
||||
result += buffer
|
||||
|
||||
return result
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user