I want to know the original country of a website. I noticed that Alexa website开发者_高级运维 can often detect the original country of websites. For example, Alexa can detect that the original country of stackoverflow.com website is USA and so on. How Alexa do this? and how i can do this? Thank You..
You can always read the country of any website from Alexa's Data from XML
core data
http://data.alexa.com/data?cli=10&url=http://www.flipkart.com
full data
http://data.alexa.com/data?cli=10&dat=snbamz&url=http://www.flipkart.com
It will be more reliable and easier than any other self developed approach
The other answers are fine, but bear in mind that many DNS registrations are protected by anonymization services, and that many sites are also hosted by providers in countries other than the one where the site's owner is.
example.com
could be physically hosted on an American ISP's server, DNS provided by a Canadian company, and the site's owning company could be in Lesotho. You just can't tell these days.
In whois protocol you have one information "country" witch you must use it.
You could get this information out of the IP of a domain. You would need an IP-to-country database to look up that country.
Try this http://www.ip2country.net/
Most likely checks the DNS data for given domain
http://en.wikipedia.org/wiki/Whois
You can do a WHOIS lookup as mentioned in other answers to get the information about the website that were stored by the registrar and filled in by the user. But you rely on an existing database of user-entered information and not actual technical data.
You can use a an IP geo-localisation service to get the location based on the IP. This may not always work for all IPs. You could also do this for all the hops you go through, which you can list by doing a traceroute (with tracert on Windows or traceroute on *NIX) and see where your request is travelling to.
精彩评论