Last active
September 11, 2018 01:05
-
-
Save gmic/97f991899a6d2544f084 to your computer and use it in GitHub Desktop.
Python nslookup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
process = subprocess.Popen(["nslookup", "www.google.com"], stdout=subprocess.PIPE) | |
output = process.communicate()[0].split('\n') | |
ip_arr = [] | |
for data in output: | |
if 'Address' in data: | |
ip_arr.append(data.replace('Address: ','')) | |
ip_arr.pop(0) | |
print ip_arr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment