Advertisement
Guest User

banebo

a guest
Jun 24th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.96 KB | None | 0 0
  1. import requests
  2. from getpass import getpass
  3. from terminaltables import AsciiTable
  4.  
  5. username = input("Unesite username: ")
  6. password = getpass()
  7. session = requests.Session()
  8. login = session.post("https://eportal.pmf.uns.ac.rs/ePMFWebServisi/login",
  9. json={"username": username, "password":password })
  10. username = login.json().get("username")
  11. token = login.json().get("authtoken")
  12. session.headers.update({"username":username, "authtoken":token})
  13. data = session.get("https://eportal.pmf.uns.ac.rs/ePMFWebServisi/ispiti/getIspitiTekuciPlan")
  14. ispiti = data.json()
  15.  
  16. zbirOcena = 0
  17. zbir = 0
  18.  
  19. table_data = [['Predmet', "Ocena", "espb"]]
  20. for ispit in ispiti:
  21.     table_data.append([ispit.get('naziv'), ispit.get('ocena'), ispit.get('espb')])
  22.     zbir += ispit.get('espb')
  23.     zbirOcena += int(ispit.get('ocena'))
  24.  
  25. table_data.append(['', zbirOcena/len(ispiti), zbir])
  26. table_view = AsciiTable(table_data)
  27. table_view.inner_footing_row_border = True
  28. print(table_view.table)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement