Skip to content

Instantly share code, notes, and snippets.

@jwc20
Created April 13, 2024 06:00
Show Gist options
  • Save jwc20/675f0b284678f57d9c90b1154ae6c49e to your computer and use it in GitHub Desktop.
Save jwc20/675f0b284678f57d9c90b1154ae6c49e to your computer and use it in GitHub Desktop.
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'])
www.google.com
www.youtube.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment