Posts Tagged ‘Python’

Find a decent untaken domain with Python

Wednesday, August 26th, 2009

                              
Ever tried using whois? Chances are, most (if not all) the domains you looked for were already taken, either as websites or just by domain squatters hoping to rip off some innocent domain consumer.

Well if you’re looking for a new domain and have a mental block on which name to choose, give this little script a try. It’ll randomly select a word from the linux dictionary, check if that domain is taken or not, and repeat.

Edit the lines near the top for different functionality as so:

  • pause = 1.0
    • The amount of seconds to wait between each whois check (you don’t want to be DoSing the whois servers.)
  • printtaken = False
    • Set this to True to print out every domain that is tried, or False to only print out the Available domains.
  • doubleword = False
    • To make your searches more probable, set this to true and it will concatenate 2 random words for you domain i.e. http://blue-eggs.com
  • nomatch = “No match for”
    • The program looks through the output of the whois command to find this string, which signifies an available domain. This may need to be changed when searching through different TLDs.
  • error = “Maximum Daily connection limit reached”
    • Similar to the above, but stops the program if there is the error found.

Run this program either with a TLD as an argument, or just on its own for .com TLDs. To close it just use Ctrl-c

#!/usr/bin/env python
# Name    : DomCheck
# Author  : Mike Terzza http://terzza.com
# Version : 0.2
# Date    : 26-08-09

import commands, string, random, time, sys

#Edit these options to change the program behaviour
###################################################
pause = 2.0
printtaken = False
doubleword = False
nomatch = "No match for"
error = "Maximum Daily connection limit reached"
###################################################

if len(sys.argv) > 1:
    tld = sys.argv[1]
else:
    tld = ".com"

words = open("/usr/share/dict/words").readlines()
while True:
    randword = words[random.randint(0, len(words))]
    if doubleword:
        randword += "-" + words[random.randint(0, len(words))]
    available = False
    temp = ""
    for letter in randword:
        if letter.lower() in string.ascii_lowercase + ".-":
            temp += letter.lower()
    output = commands.getstatusoutput("whois " + temp + tld)
    for line in output[1:]:
        if nomatch in line:
            available = True
        if error in line:
            print error
            sys.exit(0)
    if available:
        print "%s AVAILABLE" % (temp + tld + ((40 - len(temp))* "-"))
    else:
        if printtaken:
            print temp + tld
    time.sleep(pause)

Example outputs:


$ ./domcheck.py
phonologists.com---------------------------- AVAILABLE
recifes.com--------------------------------- AVAILABLE
axums.com----------------------------------- AVAILABLE
festivitys.com------------------------------ AVAILABLE
tillages.com-------------------------------- AVAILABLE
acetylenes.com------------------------------ AVAILABLE
bissaus.com--------------------------------- AVAILABLE
livelinesss.com----------------------------- AVAILABLE
apotheosizes.com---------------------------- AVAILABLE
dependabilitys.com-------------------------- AVAILABLE
sprightlier.com----------------------------- AVAILABLE

$ ./domcheck.py .co.uk
barentss.co.uk-------------------------------- AVAILABLE
stalenesss.co.uk------------------------------ AVAILABLE
lobbed.co.uk---------------------------------- AVAILABLE
raiments.co.uk-------------------------------- AVAILABLE
pluralize.co.uk------------------------------- AVAILABLE
outstretches.co.uk---------------------------- AVAILABLE
wickednesss.co.uk----------------------------- AVAILABLE
coincided.co.uk------------------------------- AVAILABLE
cuspid.co.uk---------------------------------- AVAILABLE
thirded.co.uk--------------------------------- AVAILABLE
haemoglobins.co.uk---------------------------- AVAILABLE
propellants.co.uk----------------------------- AVAILABLE

WARNING

If you run this too often or for too long you will be temporarily (and maybe even permanently) blocked from the whois lookup database. Use sparingly and at you own risk.

This is written for linux, but could be used on Windows if you install a command line based whois tool, and acquire a text file full of words. Add a comment if you need any help with it.

Download the source file here :

domcheck.tar.gz

[python]

HoT (Heads or Tails) N95, PyS60 Accelerometer app

Tuesday, August 25th, 2009

                              
Here’s another little app for your Symbian based phone. Run the script from the python interpreter and give the phone a “flip”. The accelerometer detects the flipping motion and the coin starts to spin, and stops randomly on either heads or tails and speaks the results to you in it’s own little voice.

You will need to have the script and images in the folder”c:\Data\HoT\” on your phone. plus the PyS60 interpreter and the AXYZ module to interface with the accelerometer.

HoT was originally written fro the N95 but could easily be ported to other Symbian phones with an accelerometer, or modified to flip on a keypress if you don’t have a built in accelerometer.

Check out the video:

I aim to add more features and compile it to a sis / sisx file eventually, but for now I thought I’d just upload it as an example of a working S60 script for you to play with.

Download the source:

HoT.tar.gz

HoT.zip