[Tutor] Whois
Øyvind
python at kapitalisten.no
Sun Jan 15 13:33:46 CET 2006
Hello.
I am trying to write a module that lets me check whois-info of ip-adresses:
import socket
class whois:
pass
def ip(self, adresse):
self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.s.connect(('whois.ripe.net', 43))
#self.s.connect(('whois.norid.no', 43))
self.s.send("%s \n\n" % adresse)
self.data = self.s.recv(8196)
self.page = ''
self.page = self.page + self.data
return self.page
If I run the module I get the following:
>>import whois
>>from whois import *
>>n = whois()
>>n.ip('193.12.32.16')
'% This is the RIPE Whois query server #2.\n% The objects are in RPSL
format.\n%\n% Note: the default output of the RIPE Whois server\n% is
changed. Your tools may need to be adjusted. See\n%
http://www.ripe.net/db/news/abuse-proposal-20050331.html\n% for more
details.\n%\n% Rights restricted by copyright.\n% See
http://www.ripe.net/db/copyright.html\n\n'
This is just the first part of the whois-info.
However, if I don't write it into a function:
>>import socket
>>s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>s.connect(('whois.ripe.net', 43))
>>s.send("%s \n\n" % '193.12.32.16')
15
>>data = s.recv(8196)
>>page = ''
>>page = page + data
>>page
'% This is the RIPE Whois query server #2.\n% The objects are in RPSL
format.\n%\n% Note: the default output of the RIPE Whois server\n% is
changed. Your tools may need to be adjusted. See\n%
http://www.ripe.net/db/news/abuse-proposal-20050331.html\n% for more
details.\n%\n% Rights restricted by copyright.\n% See
http://www.ripe.net/db/copyright.html\n\n% Note: This output has been
filtered.\n% To receive output for a database update, use the "-B"
flag\n\n% Information related to \'193.12.32.0 -
193.12.39.255\'\n\ninetnum: 193.12.32.0 - 193.12.39.255\nnetname:
SE-CLAVISTER-NET\ndescr: Clavister AB/\xd6vikshem KabelTV\n
tidigare Enternet Sweden AB\n \xd6rnsk\xf6ldsvik\n
####################################\n In case of
improper use, please mail\n registry at clavister.com or
abuse at swip.net\n................and so forth.
Now I get everything, not only the first part as I did above. Why? And
what should I do with the module in order to get all the info?
Thanks in advance.
--
This email has been scanned for viruses & spam by Decna as - www.decna.no
Denne e-posten er sjekket for virus & spam av Decna as - www.decna.no
More information about the Tutor
mailing list