Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. import requests
  2. from bs4 import BeautifulSoup
  3. import matplotlib.pyplot as plt
  4. from mpl_toolkits.basemap import Basemap
  5. import numpy as np
  6. from itertools import chain, zip_longest
  7. #filght parsing
  8. SITE = 'https://ru.flightaware.com/live/flight/SAS983/history/20190423/1355Z/EKCH/RJAA/tracklog'
  9. TITLE = 'График полета самолета: SAS983'
  10. r = requests.get(SITE)
  11. html=r.text
  12. soup = BeautifulSoup(html, 'lxml')
  13. trs1 = soup.find('table', {'class':'prettyTable fullWidth'}).find_all('tr',
  14. {'class':'smallrow1'})
  15. trs2 = soup.find('table', {'class':'prettyTable fullWidth'}).find_all('tr',
  16. {'class':'smallrow2'})
  17. trs1 = trs1[6:]
  18. trs = [i for i in chain.from_iterable(zip_longest(trs1, trs2)) if i is not None]
  19. X = []
  20. Y = []
  21. for tr in trs:
  22. tds = tr.find_all('td', {'align':'right'})
  23. if(len(tds) != 0):
  24. Y.append(float(tds[0].find('span').text))
  25. X.append(float(tds[1].find('span').text))
  26. print(X)
  27. print()
  28. print(Y)
  29. #map drawing
  30. m = Basemap(projection='cyl')
  31. m.drawcoastlines()
  32. m.drawmapboundary(fill_color='white')
  33. m.drawparallels(np.arange(-180.0, 180.0, 20),labels=[1,0,0,0], fontsize =14)
  34. m.drawmeridians(np.arange(-180.0, 180.0, 60),labels=[0,0,0,1], fontsize =14)
  35. plt.title(TITLE, fontsize =14)
  36. x, y = m(X[0], Y[0])
  37. m.scatter(x,y,50,marker='o',color='r')
  38. if(len(X) > 7 and len(Y) > 7):
  39. x, y = m(X[7:], Y[7:])
  40. m.scatter(x,y,30,marker='o',color='g')
  41. else:
  42. x, y = m(X, Y)
  43. m.scatter(x,y,30,marker='o',color='g')
  44. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement