-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathrec1.py
32 lines (26 loc) · 768 Bytes
/
rec1.py
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
import sys #for using commandline arg
import requests
import socket
import json
import whois
#to check arg is provided or not
if (len(sys.argv)<2):
print("usage: " + sys.argv[0] + "<url>")
sys.exit()
print(sys.argv[1])
req = requests.get("https://" + sys.argv[1])
print("\n"+str(req.headers))
print()
get_host = socket.gethostbyname(sys.argv[1])
print("the ip address of " + sys.argv[1] + " is: " + get_host)
print()
#ip info.io api for get host loaction
req_2 = requests.get("https://ipinfo.io/" + get_host + "/json")
respo = json.loads(req_2.text)
print("Location: " + respo["loc"])
print("Region: " + respo["region"])
print("City: " + respo["city"])
print("Country: " + respo["country"])
print()
whois_info = whois.whois(sys.argv[1])
print(whois_info)