forked from talsafran/domainr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
domainr
executable file
·42 lines (32 loc) · 1.04 KB
/
domainr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/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):
for arg in args:
print "Looking up domains for %s..." % arg
con = HTTPSConnection('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:])