Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 51cbe3633e
Fetching contributors…

Cannot retrieve contributors at this time

executable file 43 lines (32 sloc) 1.092 kb
#!/usr/bin/env python
from sys import argv
from httplib import HTTPConnection
import json
colors = {
'green': '\033[92m',
'yellow': '\033[93m',
'red': '\033[91m',
'endc': '\033[0m'
}
status_color = {
'available': colors['green'],
'maybe': colors['yellow'],
'taken': colors['red'],
'unavailable': colors['red']
}
def main(args):
for arg in args:
print "Looking up domains for %s..." % arg
con = HTTPConnection('domai.nr')
req = con.request('GET', '/api/json/search?q=%s' % arg)
res = con.getresponse()
if res.status == 200:
data = res.read()
sites = json.loads(data)
for s in sites['results']:
status = "%s%s - %s" % (s['domain'], s['path'], s['availability'])
print "\t" + status_color.get(s['availability'], '') + status + colors['endc']
else:
print "Uh oh, you got a %s %s. What the dilly?" % (res.status, res.reason)
if __name__ == "__main__":
main(argv[1:])
Jump to Line
Something went wrong with that request. Please try again.