Skip to content

Commit 416ab28

Browse files
committed
update all things
1 parent 9b2414f commit 416ab28

File tree

4 files changed

+219
-1
lines changed

4 files changed

+219
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
__pycache__/
33
*.py[cod]
44
*$py.class
5+
.idea
56

67
# C extensions
78
*.so

README.md

+93-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,93 @@
1-
# Phone-number-location-tracker-using-python
1+
2+
# Phone Number Location Tracker using Python
3+
4+
In this project, you can track any phone number location according to country code.
5+
6+
To make this project you need to follow this step:-
7+
8+
9+
10+
11+
12+
13+
14+
15+
## Installation
16+
17+
Install package with pip
18+
19+
```bash
20+
pip install phonenumbers
21+
pip install folium
22+
pip install geocoder
23+
pip install opencage
24+
```
25+
26+
Now need to collect Geocoder API Key from https://opencagedata.com/
27+
28+
Step1: Need to log in or sign up
29+
30+
![github1](https://user-images.githubusercontent.com/123636419/215339770-3cc5ba46-d502-42b9-9f15-856718cf22d1.PNG)
31+
32+
Step2: Need to click Geocoding API
33+
34+
![github2](https://user-images.githubusercontent.com/123636419/215339775-89aef127-2390-4f8d-8ad6-1129789eabab.PNG)
35+
36+
Step3: From API Keys collect API key
37+
38+
![github3](https://user-images.githubusercontent.com/123636419/215339773-0171d38c-b9ad-490a-95d8-47366321048a.PNG)
39+
40+
41+
42+
43+
## Deployment
44+
45+
To deploy this project run
46+
47+
```bash
48+
import phonenumbers
49+
from phonenumbers import geocoder
50+
from phonenumbers import carrier
51+
import opencage
52+
from opencage.geocoder import OpenCageGeocode
53+
import folium
54+
55+
56+
key = "your key" #Geocoder API Key need to paste here "your key"
57+
number = input("please giver your number: ")
58+
new_number = phonenumbers.parse(number)
59+
location = geocoder.description_for_number(new_number, "en")
60+
print(location)
61+
62+
service_name = carrier.name_for_number(new_number,"en")
63+
print(service_name)
64+
65+
geocoder = OpenCageGeocode(key)
66+
query = str(location)
67+
result = geocoder.geocode(query)
68+
#print(result)
69+
70+
lat = result[0]['geometry']['lat']
71+
lng = result[0]['geometry']['lng']
72+
73+
print(lat,lng)
74+
75+
my_map = folium.Map(location=[lat,lng], zoom_start=9)
76+
folium.Marker([lat, lng], popup= location).add_to(my_map)
77+
78+
my_map.save("location.html")
79+
80+
print("location tracking completed")
81+
print("Thank you")
82+
```
83+
84+
85+
You can follow me
86+
87+
Facebook:- https://www.facebook.com/problemsolvewithridoy/
88+
89+
Linkedin:- https://www.linkedin.com/in/ridoyhossain/
90+
91+
YouTube:- https://www.youtube.com/@problemsolvewithridoy
92+
93+
Thank you

location.html

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
5+
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
6+
7+
<script>
8+
L_NO_TOUCH = false;
9+
L_DISABLE_3D = false;
10+
</script>
11+
12+
<style>html, body {width: 100%;height: 100%;margin: 0;padding: 0;}</style>
13+
<style>#map {position:absolute;top:0;bottom:0;right:0;left:0;}</style>
14+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/leaflet.js"></script>
15+
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
16+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
17+
<script src="https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js"></script>
18+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/leaflet.css"/>
19+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"/>
20+
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css"/>
21+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/css/all.min.css"/>
22+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css"/>
23+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/leaflet.awesome.rotate.min.css"/>
24+
25+
<meta name="viewport" content="width=device-width,
26+
initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
27+
<style>
28+
#map_b83bc1d14c121849d16b48be1becf33b {
29+
position: relative;
30+
width: 100.0%;
31+
height: 100.0%;
32+
left: 0.0%;
33+
top: 0.0%;
34+
}
35+
.leaflet-container { font-size: 1rem; }
36+
</style>
37+
38+
</head>
39+
<body>
40+
41+
42+
<div class="folium-map" id="map_b83bc1d14c121849d16b48be1becf33b" ></div>
43+
44+
</body>
45+
<script>
46+
47+
48+
var map_b83bc1d14c121849d16b48be1becf33b = L.map(
49+
"map_b83bc1d14c121849d16b48be1becf33b",
50+
{
51+
center: [24.4769288, 90.2934413],
52+
crs: L.CRS.EPSG3857,
53+
zoom: 9,
54+
zoomControl: true,
55+
preferCanvas: false,
56+
}
57+
);
58+
59+
60+
61+
62+
63+
var tile_layer_e71ed06d487bbd75571d7c6f2eba079d = L.tileLayer(
64+
"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
65+
{"attribution": "Data by \u0026copy; \u003ca target=\"_blank\" href=\"http://openstreetmap.org\"\u003eOpenStreetMap\u003c/a\u003e, under \u003ca target=\"_blank\" href=\"http://www.openstreetmap.org/copyright\"\u003eODbL\u003c/a\u003e.", "detectRetina": false, "maxNativeZoom": 18, "maxZoom": 18, "minZoom": 0, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false}
66+
).addTo(map_b83bc1d14c121849d16b48be1becf33b);
67+
68+
69+
var marker_4b68cb1554ecffbc410e4185c6de0e32 = L.marker(
70+
[24.4769288, 90.2934413],
71+
{}
72+
).addTo(map_b83bc1d14c121849d16b48be1becf33b);
73+
74+
75+
var popup_36c60e68bfe9e8ba2dc711c02b5deaef = L.popup({"maxWidth": "100%"});
76+
77+
78+
79+
var html_4176df32f60a82a07bda363fe92a2acf = $(`<div id="html_4176df32f60a82a07bda363fe92a2acf" style="width: 100.0%; height: 100.0%;">Bangladesh</div>`)[0];
80+
popup_36c60e68bfe9e8ba2dc711c02b5deaef.setContent(html_4176df32f60a82a07bda363fe92a2acf);
81+
82+
83+
84+
marker_4b68cb1554ecffbc410e4185c6de0e32.bindPopup(popup_36c60e68bfe9e8ba2dc711c02b5deaef)
85+
;
86+
87+
88+
89+
</script>
90+
</html>

main.py

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import phonenumbers
2+
from phonenumbers import geocoder
3+
from phonenumbers import carrier
4+
import opencage
5+
from opencage.geocoder import OpenCageGeocode
6+
from myphone import key
7+
import folium
8+
9+
10+
number = input("please giver your number: ")
11+
new_number = phonenumbers.parse(number)
12+
location = geocoder.description_for_number(new_number, "en")
13+
print(location)
14+
15+
service_name = carrier.name_for_number(new_number,"en")
16+
print(service_name)
17+
18+
geocoder = OpenCageGeocode(key)
19+
query = str(location)
20+
result = geocoder.geocode(query)
21+
#print(result)
22+
23+
lat = result[0]['geometry']['lat']
24+
lng = result[0]['geometry']['lng']
25+
26+
print(lat,lng)
27+
28+
my_map = folium.Map(location=[lat,lng], zoom_start=9)
29+
folium.Marker([lat, lng], popup= location).add_to(my_map)
30+
31+
my_map.save("location.html")
32+
33+
print("location tracking completed")
34+
print("Thank you")
35+

0 commit comments

Comments
 (0)