Hello,
I am working on a 2 individual programs. In the first program, I am taking in a
list of domains in .csv format and want to get the associated IPs.
In the second program, I want to import in a list of IP .csv and than get the
associated domains out.
Eventually I want to get both of the above programs to write out to the same
.csv file that they are reading from- in the next column. But I am not there
yet.
Doing research I came across the following
example:http://python.about.com/od/pythonstandardlibrary/qt/dnscheck.htm
From the link above, doing domain -> IP would be easier to begin with. Here are
the two variations of my code:
Variation 1:
import csv
import socket
domains = open('top500domains.csv', 'r')
for domain in domains:
domain = socket.gethostbyname(str(domains))
print(domains + "\n")
For the code above, I receive the following error on run: socket.gaierror:
[Errno -2] Name or service not known.
Variation 2:
import csv
import socketdomains = []
with open('top500domains.csv', 'r') as f:
for line in f:
line = line.strip()
domains.append(line)
hostbyname_ex = socket.gethostbyname_ex(str(domains))
print(hostbyname_ex)
I receive the same error as the first variation.
Please share your advice and let me know what I am doing wrong. The
top500domains.csv list is attached.
Thanks in advance!
Thank you.
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor