سؤال

I use this code to check domain availability:

try:
    w = pywhois.whois('honarasai.com')
    if not w:
        message='Domain is available'
except:
    message='Domain is taken'

It returns this result:

creation_date: ['11-jun-2012'] domain_name: ['HONARASAI.COM', 'honarasai.com'] emails: ['domain@netafraz.com', 'domain@netafraz.com', 'domain@netafraz.com', 'domain@netafraz.com'] expiration_date: ['11-jun-2013'] name_servers: ['NS.HONARASAI.COM', 'NS2.HONARASAI.COM'] referral_url: ['http://www.OnlineNIC.com'] registrar: ['ONLINENIC, INC.'] status: ['clientTransferProhibited'] updated_date: ['11-jun-2012'] whois_server: ['whois.onlinenic.com']

When internet speed is low it doesn't work stable and return wrong result. What is an accurate way to check the result to get a stable response?

هل كانت مفيدة؟

المحلول

"internet speed is low" certainly means your request times out. You can catch that by specifying an exception on your except line:

except socket.timeout:

If you catch such an exception, you'll have to retry your request again later.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top