Advertisement
Forzaferrarileo

Untitled

Aug 20th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.90 KB | None | 0 0
  1. try:
  2.   # Python 2 import
  3.   from xmlrpclib import Server
  4. except ImportError:
  5.   # Python 3 import
  6.   from xmlrpc.client import Server
  7.  
  8. from pprint import pprint
  9.  
  10. log = open("test", "w")
  11.  
  12. DEV_KEY = 'chiave'
  13.  
  14. s1 = Server('http://muovi.roma.it/ws/xml/autenticazione/1')
  15. s2 = Server('http://muovi.roma.it/ws/xml/paline/7')
  16.  
  17. token = s1.autenticazione.Accedi(DEV_KEY, '')
  18.  
  19. res = s2.paline.GetVeicoliTuttiPercorsi(token)
  20.  
  21. numbus = 0
  22.  
  23. #array risposta
  24. risposta = res['risposta']
  25.  
  26. #numero percorsi
  27. nperc = len(risposta)
  28.  
  29. #itero dentro l'array
  30. for t in range(0,nperc):
  31.    
  32.     #dizionario percorso
  33.     percorso = risposta[t]
  34.     #id percorso
  35.     id_percorso = percorso['id_percorso']
  36.     #array arrivi
  37.     arrivi = percorso['arrivi']
  38.     arrsize = len(arrivi)
  39.  
  40.     for p in range (0, arrsize):
  41.        
  42.         vettura = arrivi[p]
  43.         id_veic = vettura['id_veicolo']
  44.         pprint(id_veic)
  45.         numbus+=1
  46.  
  47. pprint(numbus)
  48. pprint(res, log)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement