Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 44 lines (32 sloc) 1.07 KB
#!/usr/bin/env python
from sys import argv
from httplib import HTTPSConnection
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):
con = HTTPSConnection('api.domainr.com')
for arg in args:
print "Looking up domains for %s..." % arg
req = con.request('GET', '/v1/search?q=%s&client_id={your-mashape-key}' % 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:])