-
Notifications
You must be signed in to change notification settings - Fork 0
/
try3.py
417 lines (218 loc) · 12 KB
/
try3.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
#pip install requests-html
#pip install gmplot
#pip install bs4
#install these modules by using the pip command in the terminal
import requests
from bs4 import BeautifulSoup
import gmplot
latlist = [] #a list to hold latitudes
longlist = [] #a list to hold longitudes
count = input("Enter the country in top 5 leagues you want the succesful clubs' location for ")
if count.lower() == "england" or count.lower() == 'e':
for i in range(4):
if i == 0:
print("1. Manchester United FC")
url = 'https://www.findlatitudeandlongitude.com/l/old+trafford'
page = requests.get(url)
soup = BeautifulSoup(page.content, "html.parser")
lat = soup.find_all('span', class_ = 'value green')[0].get_text() #finds the latitude coordinate in the site, and gets the text
lon = soup.find(id = 'lon_address').get_text()
# lon gets longitude value, I used id here because both latitude and longitude have the same span name and and class name.
lon1 = lon.replace('Longitude:','') #I got Longitude: (value), annoying I know, but as the fields are same for both
# latitude and longitude I HAD to use id and it came with this Longitude.
latlist.append(float(lat)) #appends the latitude's float value, as get_text() gets string.
longlist.append(float(lon1)) #same as the latitude one.
elif i == 1:
#Same routine, different URL.
print("2. Liverpool FC")
url = 'https://www.findlatitudeandlongitude.com/l/anfield'
page = requests.get(url)
soup = BeautifulSoup(page.content, "html.parser")
lat = soup.find_all('span', class_ = 'value green')[0].get_text()
lon = soup.find(id = 'lon_address').get_text()
lon1 = lon.replace('Longitude:','')
latlist.append(float(lat))
longlist.append(float(lon1))
elif i == 2:
print("3. Arsenal FC")
url = 'https://www.findlatitudeandlongitude.com/l/emirates+stadium'
page = requests.get(url)
soup = BeautifulSoup(page.content, "html.parser")
lat = soup.find_all('span', class_ = 'value green')[0].get_text()
lon = soup.find(id = 'lon_address').get_text()
lon1 = lon.replace('Longitude:','')
latlist.append(float(lat))
longlist.append(float(lon1))
elif i == 3:
print("4. Chelsea FC")
url = 'https://www.findlatitudeandlongitude.com/l/stamford+bridge'
page = requests.get(url)
soup = BeautifulSoup(page.content, "html.parser")
lat = soup.find_all('span', class_ = 'value green')[0].get_text()
lon = soup.find(id = 'lon_address').get_text()
lon1 = lon.replace('Longitude:','')
latlist.append(float(lat))
longlist.append(float(lon1))
print("The coordinates of the most successful English Clubs' stadiums are given by: ")
print("Latitudes : ")
print(latlist)
print("Longitudes : ")
print(longlist)
gmap = gmplot.GoogleMapPlotter(51.509865, -0.118092, 5) #Gives the base location, basically the location of the capital, here, london
elif count.lower() == "spain" or count.lower() == 's' or count.lower() == 'espana':
#Same routine as in 'england'
for i in range(4):
if i == 0:
print("1. Futbol Club Barcelona")
url = 'https://www.findlatitudeandlongitude.com/l/camp+nou'
page = requests.get(url)
soup = BeautifulSoup(page.content, "html.parser")
lat = soup.find_all('span', class_ = 'value green')[0].get_text()
lon = soup.find(id = 'lon_address').get_text()
lon1 = lon.replace('Longitude:','')
latlist.append(float(lat))
longlist.append(float(lon1))
elif i == 1:
print("2. Real Madrid Club Futbol")
url = 'https://www.findlatitudeandlongitude.com/l/santiago+bernabeu'
page = requests.get(url)
soup = BeautifulSoup(page.content, "html.parser")
lat = soup.find_all('span', class_ = 'value green')[0].get_text()
lon = soup.find(id = 'lon_address').get_text()
lon1 = lon.replace('Longitude:','')
latlist.append(float(lat))
longlist.append(float(lon1))
elif i == 2:
print("3. Athletic Club de Bilbao")
url = "https://www.findlatitudeandlongitude.com/?lat=43.264183&lon=-2.949421"
page = requests.get(url)
soup = BeautifulSoup(page.content, "html.parser")
lat = soup.find_all('span', class_ = 'value green')[0].get_text()
lon = soup.find(id = 'lon_address').get_text()
lon1 = lon.replace('Longitude:','')
latlist.append(float(lat))
longlist.append(float(lon1))
elif i == 3:
print("4. Atletico de Madrid")
url = "https://www.findlatitudeandlongitude.com/?lat=40.43628&lon=-3.599548"
page = requests.get(url)
soup = BeautifulSoup(page.content, "html.parser")
lat = soup.find_all('span', class_ = 'value green')[0].get_text()
lon = soup.find(id = 'lon_address').get_text()
lon1 = lon.replace('Longitude:','')
latlist.append(float(lat))
longlist.append(float(lon1))
print("The coordinates of the most successful Spanish Clubs' stadiums are given by: ")
print("Latitudes : ")
print(latlist)
print("Longitudes : ")
print(longlist)
gmap = gmplot.GoogleMapPlotter(40.4168, -3.7038, 5) #Base location set to Madrid
elif count.lower() == "italy" or count.lower() == 'i' or count.lower() == 'italia':
for i in range(3):
if i == 0:
print("1. Juventus")
url = 'https://www.findlatitudeandlongitude.com/l/Allianz+stadium'
page = requests.get(url)
soup = BeautifulSoup(page.content, "html.parser")
lat = soup.find_all('span', class_ = 'value green')[0].get_text()
lon = soup.find(id = 'lon_address').get_text()
lon1 = lon.replace('Longitude:','')
latlist.append(float(lat))
longlist.append(float(lon1))
elif i == 1:
print("2. AC Milan")
url = 'https://www.findlatitudeandlongitude.com/l/san+siro'
page = requests.get(url)
soup = BeautifulSoup(page.content, "html.parser")
lat = soup.find_all('span', class_ = 'value green')[0].get_text()
lon = soup.find(id = 'lon_address').get_text()
lon1 = lon.replace('Longitude:','')
latlist.append(float(lat))
longlist.append(float(lon1))
elif i == 2:
print("3. Internazionale Milano")
url = 'https://www.findlatitudeandlongitude.com/l/san+siro'
page = requests.get(url)
soup = BeautifulSoup(page.content, "html.parser")
lat = soup.find_all('span', class_ = 'value green')[0].get_text()
lon = soup.find(id = 'lon_address').get_text()
lon1 = lon.replace('Longitude:','')
latlist.append(float(lat))
longlist.append(float(lon1))
print("The coordinates of the most successful Italian Clubs' stadiums are given by: ")
print("Latitudes : ")
print(latlist)
print("Longitudes : ")
print(longlist)
gmap = gmplot.GoogleMapPlotter( 41.902782, 12.496366, 5) #Base location set to Rome
elif count.lower() == "germany" or count.lower() == 'g' or count.lower() == 'deutschland':
for i in range(3):
if i == 0:
print("1. Bayern Munich")
url = 'https://www.findlatitudeandlongitude.com/l/allianz+arena'
page = requests.get(url)
soup = BeautifulSoup(page.content, "html.parser")
lat = soup.find_all('span', class_ = 'value green')[0].get_text()
lon = soup.find(id = 'lon_address').get_text()
lon1 = lon.replace('Longitude:','')
latlist.append(float(lat))
longlist.append(float(lon1))
elif i == 1:
print("2. Borussia Dortmund")
url = 'https://www.findlatitudeandlongitude.com/l/signal+iduna+park'
page = requests.get(url)
soup = BeautifulSoup(page.content, "html.parser")
lat = soup.find_all('span', class_ = 'value green')[0].get_text()
lon = soup.find(id = 'lon_address').get_text()
lon1 = lon.replace('Longitude:','')
latlist.append(float(lat))
longlist.append(float(lon1))
elif i == 2:
print("3. Schalke 04")
url = "https://www.findlatitudeandlongitude.com/l/VELTINS-Arena,-1,-Rudi-Assauer-Platz,-Erle-Berger-Feld,-Erle,-Gelsenkirchen-Ost,-Gelsenkirchen,-North-Rhine-Westphalia,-45891,-Germany/7507645/"
page = requests.get(url)
soup = BeautifulSoup(page.content, "html.parser")
lat = soup.find_all('span', class_ = 'value green')[0].get_text()
lon = soup.find(id = 'lon_address').get_text()
lon1 = lon.replace('Longitude:','')
latlist.append(float(lat))
longlist.append(float(lon1))
print("The coordinates of the most successful German Clubs' stadiums are given by: ")
print("Latitudes : ")
print(latlist)
print("Longitudes : ")
print(longlist)
gmap = gmplot.GoogleMapPlotter( 52.5200, 13.4050, 5)
elif count.lower() == "france" or count.lower() == 'f':
for i in range(2):
if i == 0:
print("1. Paris Saint-Germain")
url = 'https://www.findlatitudeandlongitude.com/l/parc+des+princes'
page = requests.get(url)
soup = BeautifulSoup(page.content, "html.parser")
lat = soup.find_all('span', class_ = 'value green')[0].get_text()
lon = soup.find(id = 'lon_address').get_text()
lon1 = lon.replace('Longitude:','')
latlist.append(float(lat))
longlist.append(float(lon1))
elif i == 1:
print("2. Olympique de Marseille")
url = 'https://www.findlatitudeandlongitude.com/?lat=43.2698156&lon=5.3959373'
page = requests.get(url)
soup = BeautifulSoup(page.content, "html.parser")
lat = soup.find_all('span', class_ = 'value green')[0].get_text()
lon = soup.find(id = 'lon_address').get_text()
lon1 = lon.replace('Longitude:','')
latlist.append(float(lat))
longlist.append(float(lon1))
print("The coordinates of the most successful French Clubs' stadiums are given by: ")
print("Latitudes : ")
print(latlist)
print("Longitudes : ")
print(longlist)
gmap = gmplot.GoogleMapPlotter( 48.8566, 2.3522, 5) #Base location set to Paris
gmap.scatter(latlist, longlist, '#FF0000', size = 40, marker = False) #Marker = False cause I don't want pins dropping on the scattered points
gmap.polygon(latlist, longlist, color = 'cornflowerblue') #Creating a polygon made from the different points on the map
mapname = input("Enter the .html file in which in which you'd like to save ")
gmap.draw( "C:\\Users\\srira\\desktop\\"+mapname) #Creating the html file, to store the map in