Created
November 1, 2009 18:05
-
-
Save cyberdelia/223639 to your computer and use it in GitHub Desktop.
Find every available domain from a dictionary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# encoding: utf-8 | |
import sys, json, urllib | |
from optparse import OptionParser | |
def main(): | |
parser = OptionParser() | |
parser.add_option("-e", "--extension", action="append", type="string", dest="extensions", help="specify domain extension", default=[]) | |
parser.add_option("-a", "--availability", action="store", type="choice", choices=["taken", "maybe", "available", "unavailable", "tld"], dest="availability", help="specifiy level of availability", default="available") | |
parser.set_defaults(verbose=True) | |
(options, args) = parser.parse_args() | |
for line in sys.stdin: | |
domain = line.strip() | |
response = json.load(urllib.urlopen("http://domai.nr/api/json/search?q=%s" % domain)) | |
for result in response['results']: | |
if result['availability'] in [options.availability]: | |
if options.extensions: | |
for ext in options.extensions: | |
if result["domain"].endswith(ext): | |
print result['domain'] | |
else: | |
print result['domain'] | |
if __name__ == '__main__': | |
try: | |
main() | |
except (KeyboardInterrupt, SystemExit): | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment