could someone help me please? I have an output.txt file (example file) which looks like this:
output.txt:
account.netflix.com
prod.netflix.com
netflix.com
https://google.com
and I’m trying to put in a file alive.txt just only the existing url with this code
import socket
with open("output.txt", 'r') as f:
for url in f:
try:
addr1 = socket.gethostbyname(url)
print(addr1 + " is a valid url")
f = open("alive.txt", "a")
f.write("\n" + addr1)
f.close()
except:
print("not valid")
f.close()
what am I doing wrong?