tags:

views:

145

answers:

3

Hello
Is there any way to generate words based on characters and checking if a domain exists with this word (ping)?

What I want to do is to generate words based on some characters, example "abcdefgh", and then ping generatedword.com to check if it exists.

A: 

It seems like you are talking about permutations of character combinations. This has been a fairly well published recipe. That link should get you started.

One additional note, ping will not tell you if a server 'exists' or if the name is registered, only if it is online and is not behind a firewall that blocks ping traffic.

Shane C. Mason
+3  A: 

Just because a site fails a ping doesn't mean the domain is available. The domain could be reserved but not pointing anywhere, or the machine may not respond to pings, or it may just be down.

Andrew Grant
Or the host doesn't respond to ping requests (like cnn.com)
Greg
+7  A: 

You don't want to use the ping command, but you can use Python's socket.gethostbyname() function to determine whether a host exists.

def is_valid_host(hostname):
    try:
        addr = socket.gethostbyname(hostname)
    except socket.gaierror, ex:
        return False
    return True

hosts = ['abc', 'yahoo.com', 'google.com', 'nosuchagency.gov']
filter(is_valid_host, hosts)

This is going to take tons of time and maybe make your ISP mad at you. You're better off either:

  1. Using a lower-level DNS interface such as dnspython, or

  2. Finding a direct interface to domain registrars, such as whois, and querying that.

You aren't going to use this to spam people, are you?

Tim Gilbert
Thanks :)No, I'm not going to spam anyone ;), just trying to solve a puzzle
Terw
What about domain-camping?
C. Ross
Asking the DNS and asking whois does not give you identical results. For instance, in ".fr" (and probably many other registries), a domain can be registered but not activated and therefore invisible in the DNS.
bortzmeyer