I am writing an script to analyse the countries of a list of domain names(e.g. third.second.first). The data set is pretty old and many of the fully qualified domain names cannot be found via socket.gethostbyname(domain_str) in python. Here are some of the alternatives I come up with:
- Retrieving the ip of
second.firstif the ip ofthird.second.firstcannot be found and then find the country of that ip- This seems not to be a good idea since a dns A-record can map a subdomain to an ip different from its primary domain.
- detect the country code of the domain name. e.g. if it is ..jp, it is from Japan
My questions are:
- Is the first method acceptable ?
- are there other methods to retrieve the country information of a domain name ?
Thank you.