如何在 Python 中更快地验证域?

发布于 2024-11-14 19:57:34 字数 495 浏览 4 评论 0原文

有什么办法可以提高脚本验证速度吗?或者还有另一种(不是软件)解决方案?

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

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

很糊涂小朋友 2024-11-21 19:57:34

由于您的程序通常等待网络活动,因此您可能可以通过对程序进行线程化来提高速度。

话虽如此,如果你能用另一种方式做到这一点,那可能会更好。
你真正想解决什么问题?
您只是想根据您提供的示例了解哪些域名是免费的,还是您还想了解其他内容?

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?

感情废物 2024-11-21 19:57:34

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

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

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文