Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- from bs4 import BeautifulSoup
- import matplotlib.pyplot as plt
- from mpl_toolkits.basemap import Basemap
- import numpy as np
- from itertools import chain, zip_longest
- #filght parsing
- SITE = 'https://ru.flightaware.com/live/flight/SAS983/history/20190423/1355Z/EKCH/RJAA/tracklog'
- TITLE = 'График полета самолета: SAS983'
- r = requests.get(SITE)
- html=r.text
- soup = BeautifulSoup(html, 'lxml')
- trs1 = soup.find('table', {'class':'prettyTable fullWidth'}).find_all('tr',
- {'class':'smallrow1'})
- trs2 = soup.find('table', {'class':'prettyTable fullWidth'}).find_all('tr',
- {'class':'smallrow2'})
- trs1 = trs1[6:]
- trs = [i for i in chain.from_iterable(zip_longest(trs1, trs2)) if i is not None]
- X = []
- Y = []
- for tr in trs:
- tds = tr.find_all('td', {'align':'right'})
- if(len(tds) != 0):
- Y.append(float(tds[0].find('span').text))
- X.append(float(tds[1].find('span').text))
- print(X)
- print()
- print(Y)
- #map drawing
- m = Basemap(projection='cyl')
- m.drawcoastlines()
- m.drawmapboundary(fill_color='white')
- m.drawparallels(np.arange(-180.0, 180.0, 20),labels=[1,0,0,0], fontsize =14)
- m.drawmeridians(np.arange(-180.0, 180.0, 60),labels=[0,0,0,1], fontsize =14)
- plt.title(TITLE, fontsize =14)
- x, y = m(X[0], Y[0])
- m.scatter(x,y,50,marker='o',color='r')
- if(len(X) > 7 and len(Y) > 7):
- x, y = m(X[7:], Y[7:])
- m.scatter(x,y,30,marker='o',color='g')
- else:
- x, y = m(X, Y)
- m.scatter(x,y,30,marker='o',color='g')
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement