find country from full domain name

Viewed 2811

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:

  1. Retrieving the ip of second.first if the ip of third.second.first cannot 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.
  2. 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.

1 Answers
Related