-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLocation.py
More file actions
52 lines (38 loc) · 1.45 KB
/
Location.py
File metadata and controls
52 lines (38 loc) · 1.45 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
import os.path
import requests
import time
from datetime import datetime
import random
import uuid
# Get Target [Country , City , Language , IPV4 , IPV4 , MAC , LTude,LTude , Others ... ] Location information
# 8/13/2025
# AUX-441
class Request_Location:
def Location(self):
try:
url = "https://ident.me/json"
response = requests.get(url)
if response.status_code == 200:
data = response.json()
time.sleep(random.randint(1, 3))
folder = "full_informations"
path = "location.txt"
full = os.path.join(folder, path)
if not os.path.exists(folder):
os.makedirs(folder)
with open(full, "a", encoding="utf-8") as file:
file.write("=" * 40 + "\n")
file.write("Your information :\n")
file.write("=" * 40 + "\n")
for key, value in data.items():
file.write(f"{key.capitalize()}: {value}\n")
file.write("=" * 40 + "\n\n")
else:
print(f"Failed to Get information Error code : {response.status_code}")
except requests.exceptions.RequestException as e:
print(f"Connection Failed : {e}")
except ValueError:
print("Wrong Answer from JSON ...")
if __name__ == "__main__":
C = Request_Location()
C.Location()