Stanyko
Stanyko

Reputation: 195

How to verify domains faster in Python?

Is there any way how to improve scripts verification speed? Or there is another (not a sw) solution?

I tried something like this (but its slow and useless):

import urllib
from socket import * 
import string, re

strings = string.ascii_lowercase
digits = string.digits

def validate(url):
    try:
        targetIP = gethostbyname(url)
        print url,' - Registered - ', targetIP
    except:
        print url," - Free"

def generate(url):

    for x in strings:      
        url_mod = "www."+ x + url
        validate(url_mod)

generate("atrion.com")

Upvotes: 2

Views: 537

Answers (2)

Nemo
Nemo

Reputation: 71515

Your speed problem comes from looking up the domain in the DNS, not from Python.

I would try configuring my system to use a different DNS server, like the Google Public DNS. Note that this is a system-level configuration, not a Python configuration. You can find a link to configuration instructions on that page.

Note also that if you are making a lot of such queries, Google might interpret it as a denial-of-service attack and cut you off. Just FYI.

Upvotes: 1

Mattias Nilsson
Mattias Nilsson

Reputation: 3757

Since your program typically waits for network activity, you can probably get a speed-up by threading your program.

Having said that, if you can do this in another way, that would probably be preferrable. What problem are you really trying to solve? Do you just want to find out what domain names are free according to the example you provided or is there something else you are after?

Upvotes: 2

Related Questions