Skip to content

Instantly share code, notes, and snippets.

@mritunjay-k
Last active April 30, 2019 01:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mritunjay-k/c8e237efcd6d821c2f9d4d1911ab9d47 to your computer and use it in GitHub Desktop.
Save mritunjay-k/c8e237efcd6d821c2f9d4d1911ab9d47 to your computer and use it in GitHub Desktop.
Check if a domain in up or not..!!
#!/usr/bin/env python
import socket
try:
domain = input("Enter the name of the domain: ")
ip = socket.gethostbyname(domain)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if sock.connect_ex((ip,80)) and sock.connect_ex((ip,443)):
print("Its down!!")
else:
print("Its up!!")
except:
print("Enter a valid domain name")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment