1

有什么方法可以提高脚本验证速度吗?还是有另一个(不是 sw)解决方案?

我试过这样的事情(但它很慢而且没用):

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")
4

2 回答 2

1

您的速度问题来自于在 DNS 中查找域,而不是来自 Python。

我会尝试将我的系统配置为使用不同的 DNS 服务器,例如Google Public DNS。请注意,这是系统级配置,而不是 Python 配置。您可以在该页面上找到指向配置说明的链接。

另请注意,如果您进行大量此类查询,Google 可能会将其解释为拒绝服务攻击并切断您的联系。仅供参考。

于 2011-06-09T13:32:32.287 回答
1

由于您的程序通常等待网络活动,因此您可以通过线程化程序来加快速度。

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?

于 2011-06-09T13:36:50.010 回答