[Python] DNS lookup

Platform:  Python
Published  Sep 13, 2011
Updated  Sep 24, 2011
Intro
This is an easy DNS lookup function for Python IRC bots.
Its really buggy, but that's not my script. its the "gethostbyaddr" function.

Example
<Aha2Y> !dns hawkee.com
<&System> Address : ('hawkee.com', [], ['72.9.230.138'])
<~Aha2Y> !dns hawkee..org
<&System> [ERROR] Something is wrong here!!!

How to use
Make a variable called 'chan' with the channel name.
Then simply use !dns <ip/host>

- Status -
This snippet is finished. if data.find(''+ chan +' :!dns' ) != -1:
try:
dns = data.split( ''+ chan +' :!dns' )
dnsget = dns[1].strip()
dnserv = socket.gethostbyaddr(dnsget)
irc.send ( 'PRIVMSG '+ chan +' :Address : '+ str(dnserv) +'\n' )
except:
irc.send ( 'PRIVMSG '+ chan +' :[ERROR] Something is wrong here!!!\n' )

Comments

Sign in to comment.
armagidon   -  Nov 27, 2011
use s : '+ str(dnserv[0]) +'\n' )
Dr4rqua  -  Mar 11, 2013
Why not str(dnserv[-1]) ?
Sign in to comment

Frenetic   -  Sep 13, 2011
Never-mind, it would not work out in the long run.
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.