NameSilo

Script to determine domain registrant country?

Spacemail by SpaceshipSpacemail by Spaceship
Watch

dsiomtw

Established Member
Impact
6
Anyone have any ideas how I could easily determine a domain registrant's country based on the whois info? I can't think of a way to accurately do this since whois results are not standardized. Unfortunately I really need to do this. I could hard-code the script to be able to handle the whois output from the Top 10 registrars or something like that, which would cover a lot of domains I needed to check, but that's about the best I can come up with. Unfortunately, the ones I'm primarily interested in are domains registered by people not in the US, and there are tons of non-US registrars too. Anyone have any ideas for me? Thanks!
 
Last edited:
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
Two obvious methods come to mind here:

A) Run a different extraction query for, say, the top 10 registrars' WHOIS info...
-Pros: Would find countries easily and effectively.
-Cons: Would have to make a different, custom extraction script for each registrar type.

B) Make a PHP array with all countries' names in it (one country per array element) - then just run a search to see if that string is found in the WHOIS info... then return which country it was checking for.
-Pros: Would work with practically any WHOIS entry.
-Cons: You'd just need to find a list of countries in the world somewhere on the net then put it into an array with PHP. If you find a list, I can help you put it into an array easily.


Essentially: I suggest option B.
 
0
•••
Option B would be ideal, and I thought of that too, but I've noticed that some registrars don't list the full country name. For example, it might list IN for India, etc. so that wouldn't really work too well. I'm still brainstorming on this ... so thanks a lot for your reply. If you have any other ideas I'm all ears. :)
 
0
•••
No reason you can't have IN and India in the array at the same time. You could also keep the list in a flat file so that it's easily updated whenever you need to add new countries. Just keep everything in name/value pairs and do all your searches case-insensitive

US=United States
USA=United States
IN=India
India=India
etc.

It's trivial for any scripting language to read this in and have it populate a data structure. Given that there are only, what, 170 or so countries in the world, even if you had 10 aliases for each, you'd have fewer than 2000 lines to read in and process. That's nothing for php/perl/whatever to handle in real-time.

As a followup, straight from the ISO site, their official list of country codes. It's a good place to start:

http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html
 
0
•••
What I meant was, when you parse the whois output you can't assume the country of the registrant is India just because the results contain the string "in" or "IN". It seems to me that this type of thing would generate tons of false matches. Or am I missing something here?
 
0
•••
Right, that's why you do a case-insensitive exact-match comparison as opposed to a "contains" comparison, and then list lots of variants.

That way, "in" or "india" would map to India, but Bahrain (which also contains "in") would not.

Nothing is going to be foolproof. You'll have to continually refine the process by adding more and more variants you might encounter over time. What if (for some bizarre reason) some guy registers 1,000 names in India but types the country in as Indiaaaaa? You'll just have to add that as another case. It's an ongoing process.
 
0
•••
Appraise.net

We're social

Domain Recover
DomainEasy — Live Options
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back