You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			42 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Python
		
	
			
		
		
	
	
			42 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Python
		
	
| import json
 | |
| import requests
 | |
| 
 | |
| #busstop = "\"streetID:1500001109::3101000:-1:B%C3%BCltenweg:Braunschweig:B%C3%BCltenweg::B%C3%BCltenweg:%2038106:ANY:DIVA_STREET:1172970:5148740:MRCV:NDS\""
 | |
| 
 | |
| #response = requests.get(baseUrl + "XML_DM_REQUEST?sessionID=0&outputFormat=JSON&locationServerActive=1&type_dm=any&name_dm=" + busstop)
 | |
| #if response.ok:
 | |
|     #for item in response.json()['parameters']:
 | |
|     #    if item['name'] == "sessionID":
 | |
|     #        sessionID = item['value']
 | |
|     #print("session id:" + sessionID)
 | |
| 
 | |
| #getStr = baseUrl+"XML_DM_REQUEST?sessionID="+sessionID+"&requestID=1"+"&outputFormat=JSON"+"&dmLineSelectionAll=1"
 | |
| 
 | |
| baseUrl = "https://bsvg.efa.de/bsvagstd/"
 | |
| busstop = "26000084"
 | |
| getStr = baseUrl+"XML_DM_REQUEST?"+ \
 | |
|         "outputFormat=JSON"+ \
 | |
|         "&stateless=1"+ \
 | |
|         "&locationServerActive=1" \
 | |
|         "&type_dm=stop"+ \
 | |
|         "&name_dm="+busstop+ \
 | |
|         "&useRealtime=1"+ \
 | |
|         "&mode=direct" \
 | |
|         "&ptOptionsActive=1"
 | |
| response = requests.get(getStr)
 | |
| response.encoding = 'UTF-8'
 | |
| 
 | |
| for item in response.json()['departureList']:
 | |
|     hour=item['dateTime']['hour']
 | |
|     minute=item['dateTime']['minute']
 | |
|     if len(hour) < 2:
 | |
|         hour="0"+hour
 | |
|     if len(minute) < 2:
 | |
|         minute="0"+minute
 | |
|     print(hour+":"+minute, end="\t")
 | |
|     print(item['servingLine']['number'], end="\t")
 | |
|     print(item['servingLine']['direction'])
 | |
| 
 | |
| #print(json.dumps(response.json()['departureList'], indent = 1)) 
 | |
| 
 |