Python Forum

Full Version: Get event details from eventful api
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Im trying to use the eventful api to get information about music events (concerts) between two dates. For example I want to get the below information about each concert from 20171012 to 20171013:

- city
- performer
- country
- genre
- title
- image
- StarTime

Im using a python example available online and change it to get the data above. But for now its not working Im just able to get this information:

{'latitude': '40.4',
'longitude': '-3.68333',
'start_time': '2017-10-12 20:00:00',
'city_name': 'Madrid', 'title': 'Kim Waters & Maysa Smooth en Hot Jazz Festival'}

But the performer, genre country and image its not working. Do you know how to get that information? When I change the python example below to get this information it returns always a empty array.

python example working: (However, without getting the performer, genre, country and image url, because if i add these I got an empty array)


       import requests
       import datetime
    
    def get_event(user_key, event_location , start_date, end_date, event_features, fname):
    
        data_lst = []  # output
        start_year = int(start_date[0:4])
        start_month = int(start_date[4:6])
        start_day = int(start_date[6:])
    
        end_year = int(end_date[0:4])
        end_month = int(end_date[4:6])
        end_day = int(end_date[6:])
    
        start_date = datetime.date(start_year, start_month, start_day)
        end_date = datetime.date(end_year, end_month, end_day)
        step = datetime.timedelta(days=1)
    
        while start_date <= end_date:
    
            date = str(start_date.year)
            if start_date.month < 10:
                date += '0' + str(start_date.month)
            else:
                date += str(start_date.month)
    
            if start_date.day < 10:
                date += '0' + str(start_date.day)
            else:
                date += str(start_date.day)
            date += "00"
            date += "-" + date
    
            url = "http://api.eventful.com/json/events/search?"
            url += "&app_key=" + user_key
            url += "&location=" + event_location
            url += "&date=" + date
            url += "&page_size=250"
            url += "&sort_order=popularity"
            url += "&sort_direction=descending"
            url += "&q=music"
            url+= "&c=music"
    
            data = requests.get(url).json()
    
            try:
                for i in range(len(data["events"]["event"])):
                    data_dict = {}
                    for feature in event_features:
                        data_dict[feature] = data["events"]["event"][i][feature]
                    data_lst.append(data_dict)
            except:
                pass
    
            print(data_lst)
            start_date += step
    
    
    def main():
    
        user_key = ""
        event_location = "Madrid"
        start_date = "20171012"
        end_date = "20171013"
        event_location = event_location.replace("-", " ")
        start_date = start_date
        end_date = end_date
        event_features = ["latitude", "longitude", "start_time"]
        event_features += ["city_name", "title"]
        event_fname = "events.csv"
    
        get_event(user_key, event_location, start_date, end_date, event_features, event_fname)
    
    
    if __name__ == '__main__':
        main()