Created
April 13, 2024 06:00
-
-
Save jwc20/675f0b284678f57d9c90b1154ae6c49e to your computer and use it in GitHub Desktop.
This file contains hidden or 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 socket | |
import csv | |
import subprocess | |
import os | |
with open('urls.txt', 'r') as input_file, open('results.csv', 'w', newline='') as output_file: | |
reader = csv.reader(input_file) | |
writer = csv.writer(output_file) | |
writer.writerow(['URL', 'IP Address']) | |
for row in reader: | |
url = row[0] | |
print(url) | |
try: | |
ip_address = socket.gethostbyname(url) | |
writer.writerow([url, ip_address]) | |
except: | |
writer.writerow([url, 'error']) |
This file contains hidden or 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
www.google.com | |
www.youtube.com |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment