from socket import gethostbyaddr def nslooky(ip): try: output = gethostbyaddr(ip) return output[0] except: output = "not found" return output your_ip = request.META.get('REMOTE_ADDR') # above is Django module object your_name = nslooky(your_ip)Original code by Cluther
1 comment:
For a common nslookup, you may have a better result from the following:
return ''.join(output[2])
Post a Comment