/home/shakir

Prefix WhoIs in Python

Posted on 10 Nov, 2007, categorized under Information Insemination



Part of a project I’m into requires me to dig for some details on IP addresses. Normal whois query (default to whois.apnic.net) don’t give me the information that I really need for, and upon searching I came to the Prefix Whois Project. They have came up with whob, and from the website I get to know that I can even get part of whob’s functionality by just to query for whois from their server. Let’s try with our favorite’s TMNut Screamyx DNS

 

shakir@herugrim ~ $ whois -h whois.pwhois.org 202.188.0.133
IP: 202.188.0.133
Origin-AS: 4788
Prefix: 202.188.0.0/19
AS-Path: 6079 4788
AS-Org-Name:
Org-Name: Asia Pacific Network Information Centre
Net-Name: APNIC-CIDR-BLK
Cache-Date: 1195082506
Latitude: 3.167000
Longitude: 101.700000
City: -
Region: -
Country: MALAYSIA

I’ve just started to learn, and like Python, and let’s see my Python example to extract the whois info;

import commands

def main():

    whoisServer = "whois.pwhois.org"
    IPAddr = "202.188.0.133"

    status, output = commands.getstatusoutput('whois -h ' + whoisServer + " " + IPAddr)

    result = {}

    for i in output.splitlines():
        stripped = i.split(':')
        result[stripped[0]] = stripped[1]

    print result

if __name__ == "__main__":
    main()




Looking for something else? Search Google.

No Responses to "Prefix WhoIs in Python"

Comment Form


  • si perda: wah.. boleh kasi need for speed test power skali... boleh layan network race ni...
  • Faiz: wah....harganya berapa?
  • shakir: Hmm, I have no lab and that actually was my living room :D Sure I'll move them to one of my available rooms at home and make it a lab, but that'll be
  • peja: whoaaa..at least u have ur own lab...look interesting!
  • Qing Ru: He looks really cute! Fatherhood must have been quite rewarding :)
  • shakir: Chris: Thanks, I've updated the post.
  • shakir: tak cukup banyak guinea pig yang dah try and comment on the wimax service, and so I'll just wait :D
  • shakir: Vadim: Yup, but I prefer to just install dosbox and play the game rather than re-installing my system with 32 bit Linux :D
  • Vadim: 2shakir: wine doesn't support 64-bit linux. You have to use 32-bit linux if you want to use wine.
  • kevler: yerp ...dalam 2 hari nih jer ..aku dah kesan 2 BMW X6 , kat puchong dan jalan ampang ..giler laa lawa



Disclaimer

The information in this weblog is provided "AS IS" with no warranties, and confers no rights. This weblog does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my own personal opinion. Inappropriate comments will be deleted at the authors discretion. All code samples (if any, ever) are provided "AS IS" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
Personal (Blogs) - TOP.ORG