-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetsiteinfo.py
More file actions
52 lines (43 loc) · 1.36 KB
/
getsiteinfo.py
File metadata and controls
52 lines (43 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from requests import *
from socket import *
from sys import exit
def get_ip(url, host, port=80):
client = socket(AF_INET, SOCK_STREAM)
client.connect((host, port))
print("Ip -> %s : {}".format(host) % url)
def get_info(host):
if "https://" in host:
info = get(host).headers
for i, j in info.items():
print(i, ": ", j)
else:
url = "https://"+host
info = get(url).headers
for i, j in info.items():
print(i, ": ", j)
def main():
try:
url = input(" : ")
if len(url) == 0:
print("You didn't enter any host name. Enter a url ->")
return main()
try:
ip_url = url
if "https://" in ip_url:
filter_host = ip_url.strip("https://")
host = gethostbyname(filter_host)
elif "http://" in ip_url:
filter_host = ip_url.strip("http://")
host = gethostbyname(filter_host)
else:
host = gethostbyname(url)
get_ip(url, host)
get_info(url)
except (gaierror, RequestException, UnicodeError):
print("Please Check the url. Unable to find data of: ", url)
except KeyboardInterrupt as ke:
if ke:
print("You stop the program.")
exit()
if __name__ == '__main__':
main()