0

I am going to gather and analyze the DNS registration information of a large number of domain names. My domain names are such as bbc.com, bbc.com.co, bbc.com.a and bbc.com.aa. As you can see, I have typo/squatting domain names of the official web sites such as bbc.com. I am using python whois library and send DNS whois query to these domain names, but for so many of them, I got below message: Here is my code for sending whois query :

try:
    typo_dns_info = whois.whois(typo)
    if typo_dns_info:
        typo_info[typo] = typo_dns_info
        registered_typo.append(typo)
except:
    pass

and I got this error for many of the domain names:

Socket Error: [Errno 111] Connection refused

I searched and I think maybe I need to sleep my program to send DNS query after 1 second. But it did not help me at all. I do not know what is the best way to get the whois information of a url?

1 Answers1

0

I use regular DNS queries to tell if a domain exists. Whois servers typically aren't set up for high volume queries and some limit the rate of queries on a per-IP basis. Regular DNS servers are designed for high lookup rates and will not throw the same errors.

Here's a bit of code to discover registered domains via dnspython:

try:
    dns.resolver.query(typo, 'A')
    print("%s exists" % typo)
except:
    try:
        x = whois.whois(typo)
        print("%s exists" % typo)
    except:
        print("%s doesn't exist" % typo)
Allen Luce
  • 7,859
  • 3
  • 40
  • 53
  • Thank you, but it return something for "redditi.com.CAB" which I can not understand. All of the filed of dns whois query for this typo is empty. But your code says this is exist! Is it possible? – Shahrooz Pooryousef Dec 05 '17 at 17:35
  • I think this is because the registrar (Godaddy) is answering WHOIS queries with a more general record. Insert this line after the `x = whois.whois(typo)`: `if 'domain_name' in x: assert x['domain_name'].lower() == typo.lower()` -- that'll make sure the domain listed in the whois record is the actual domain we're interested in. – Allen Luce Dec 05 '17 at 21:54
  • Thank you. I also want to check if the web sites for these typo domain names are available or not. Do you know a better way to do that? – Shahrooz Pooryousef Dec 05 '17 at 22:47
  • Do you mean check to see if there's an existing web site at (say) www.redditi.com.CAB? – Allen Luce Dec 06 '17 at 00:34
  • Domains can exist without being published. So checking DNS for domain name existence is not a good idea. – Patrick Mevzek Jan 02 '18 at 15:47