标签:
#coding=utf-8 #!/usr/bin/python import socket fo = open(‘C:\\Users\\ITvobile\\Desktop\\domainlist_all‘) fon = open(‘C:\\Users\\ITvobile\\Desktop\\addresslist.conf‘, ‘ab‘) fr = fo.readlines() fr_uni = list(set(fr)) fr_uni.sort(key=fr.index) # fr_uni = {}.fromkeys(fr).keys() # 列表元素去重for eachdomain in fr_uni: try: result = socket.getaddrinfo(eachdomain.strip(‘\n‘), None) # print ‘address=/‘ + eachdomain.strip(‘\n‘) + ‘/‘ + result[0][4][0] fon.write(‘address=/‘ + eachdomain.strip(‘\n‘) + ‘/‘ + result[0][4][0] + ‘\n‘) except socket.gaierror: pass
fon.close() fo.close()
标签:
原文地址:http://www.cnblogs.com/IvanChen/p/5033431.html