Skip to content

Instantly share code, notes, and snippets.

@weppos
Created June 7, 2012 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weppos/2890626 to your computer and use it in GitHub Desktop.
Save weppos/2890626 to your computer and use it in GitHub Desktop.
RoboWhois + Python example: get the WHOIS record for a domain.
import urllib2
def whois(domain):
api_key = "YOUR_API_KEY"
template = "http://api.robowhois.com/whois/%s"
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, "http://api.robowhois.com/", api_key, "X")
handler = urllib2.HTTPBasicAuthHandler(passman)
opener = urllib2.build_opener(handler)
request = urllib2.Request(template % domain)
response = opener.open(request)
return response.read()
print whois("google.com")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment