This repository has been archived by the owner on May 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathphone_num.py
52 lines (43 loc) · 1.8 KB
/
phone_num.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import phonenumbers
from phonenumbers import geocoder
from phonenumbers import carrier
from phonenumbers import timezone
from opencage.geocoder import OpenCageGeocode
from pprint import pprint
from phone_data import number, key
# getting phone number
ph_num = phonenumbers.parse(number)
print("[+] Phone Number: %s" % ph_num)
# testing phone number
is_possible = phonenumbers.is_possible_number(ph_num)
is_valid = phonenumbers.is_valid_number(ph_num)
inter_national_format = phonenumbers.format_number(ph_num, phonenumbers.PhoneNumberFormat.INTERNATIONAL)
print("[+] IS Valid: %s" % is_valid)
print("[+] IS Possible: %s" % is_possible)
print("[+] IN Formatted: %s" % inter_national_format)
# getting country of given phone number
ch_number = phonenumbers.parse(number, "CH")
country = geocoder.description_for_number(ch_number, "en")
print("[+] Country: %s" % country)
# getting service provider of phone number
service_provider = phonenumbers.parse(number, "RO")
service_pro = carrier.name_for_number(service_provider, "en")
print("[+] Service Provider: %s" % service_pro)
# getting time zones list
gb_number = phonenumbers.parse(number, "GB")
time_zone = timezone.time_zones_for_number(gb_number)
print("[+] Time Zone: %s" % time_zone)
geocoder = OpenCageGeocode(key)
locator = geocoder.geocode(country, no_annotations=1, language='en')
first_bounds_location = locator[0]["bounds"]
first_components_location = locator[0]['components']
first_confidence_location = locator[0]['confidence']
first_geometry_location = locator[0]['geometry']
print(f"\n[+]Bounds: \n")
pprint(first_bounds_location)
print("\n[+]Components: \n")
pprint(first_components_location)
print("\n[+]Confidence: \n")
pprint(first_confidence_location)
print("\n[+]Geometry: \n")
pprint(first_geometry_location)