Advertisement
RiseVisual

Untitled

Apr 17th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. import requests
  2.  
  3. def fetch(url):
  4. response = requests.get(url).json()
  5. return response
  6.  
  7. urls = ['http://svc.metrotransit.org/NexTrip/17940?format=json', 'http://svc.metrotransit.org/NexTrip/17928?format=json']
  8.  
  9. counter = 0
  10. firstTableHeader = '[North from Hennepin and 16th]'
  11. secondTableHeader = '[South from Hennepin and 16th]'
  12.  
  13. for url in urls:
  14. counter = counter + 1
  15. response = fetch(url)
  16. route = response[0]['Route']
  17. departureText = response[0]['DepartureText']
  18. description = response[0]['Description']
  19. arrivalTimeNextBus = response[1]['DepartureText']
  20. print(firstTableHeader)
  21. print('\n')
  22. print(f'Route:{route:<20}')
  23. print(f'Departure time of closest bus:{departureText:<20}')
  24. print(f'Description:{description:<20}')
  25. print(f'Arrival time for the next available bus is:{arrivalTimeNextBus:<20}')
  26. print('\n')
  27. print('---------------------------------------------------------------------------')
  28. firstTableHeader = secondTableHeader
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement