Jump to content

pieterm

Members
  • Posts

    4
  • Joined

  • Last visited

Posts posted by pieterm

  1. For my master thesis I need realtime GTFS data which can be retrieved and parsed with python.
    I have this script working locally.

    When executed here i get a 500 error. (Exec format error: exec of '***/cgi-bin/gtfsrealtime.py' failed: ***/cgi-bin/gtfsrealtime.py)

     

    Could it be that the modules from the google packages I'm importing are missing? (I've read on the forum that the requests package should be installed)

    Would it be possible to have them installed if so? (I am on Johnny using python 2.7)

     

    Thanks in advance!

    from google.transit import gtfs_realtime_pb2
    from google.protobuf import json_format
    import requests
    
    feed = gtfs_realtime_pb2.FeedMessage()
    response = requests.get('https://***')
    feed.ParseFromString(response.content)
    
    
    json = json_format.MessageToJson(feed)
    
    
    f = open("test.json", "w")
    f.write(json)
    
    
    for entity in feed.entity:
       if entity.HasField('trip_update'):
         print entity.trip_update
    
    f.close()
    
×
×
  • Create New...