Want to write a script to do the batch conversion from domain name to IP.

Jeff McNeil jeff at jmcneil.net
Fri Jan 30 08:41:29 EST 2009


On Jan 30, 7:33 am, Chris Rebert <c... at rebertia.com> wrote:
> On Fri, Jan 30, 2009 at 4:27 AM, Hongyi Zhao <hongyi.z... at gmail.com> wrote:
> > Hi all,
>
> > Suppose I've the entries like the following in my file:
>
> > ------------------
> > 116.52.155.237:80
> > ip-72-55-191-6.static.privatedns.com:3128
> > 222.124.135.40:80
> > 217.151.231.34:3128
> > 202.106.121.134:80
> > 211.161.197.182:80
> > hpc.be.itu.edu.tr:80
> > static3-117-183.worldinternetworkcorporation.com:80
> > ------------------
>
> > Now, I want to convert the domain name to IP by using a python script,
> > e.g.,
>
> > ip-72-55-191-6.static.privatedns.com:3128
>
> > should be converted into the following form:
>
> > 72.55.191.6:3128
>
> > any hints on this?
>
> PyDNS might be a helpful library for writing such a script --http://pydns.sourceforge.net/
>
> Cheers,
> Chris
>
> --
> Follow the path of the Iguana...http://rebertia.com

Why not just use socket.gethostbyname?

Python 2.5.2 (r252:60911, Oct  5 2008, 19:24:49)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> socket.gethostbyname('ip-72-55-191-6.static.privatedns.com')
'72.55.191.6'
>>>






More information about the Python-list mailing list