示例#1
0
def flight_query():
    origin = request.args.get('origin')
    dest = request.args.get('dest')
    freq = request.args.get('freq')
    start_date = request.args.get('start_date')
    until_date = request.args.get('until_date')
    weekdays = request.args.getlist('weekdays')


    start_date = datetime.strptime(start_date, '%m-%d-%Y')
    until_date = datetime.strptime(until_date, '%m-%d-%Y')
    weekdays = map(int, weekdays)

    #Can probably use dateutils parser for this.
    if freq == "DAILY":
        freq=DAILY

    date_pairs = generate_date_pairs(freq, weekdays, start_date, until_date)

    result = list()

    for d in date_pairs:
        flight_scraper  =   FlightScraper(origin, dest, d[0], d[1])
        v = [d[0].isoformat(), d[1].isoformat(), flight_scraper.search_flights()]
        result.append(v)

    return render_template('query.html', result=result)
示例#2
0
def flight_query():
    origin = request.args.get('origin')
    dest = request.args.get('dest')
    freq = request.args.get('freq')
    start_date = request.args.get('start_date')
    until_date = request.args.get('until_date')
    weekdays = request.args.getlist('weekdays')


    start_date = datetime.strptime(start_date, '%m-%d-%Y')
    until_date = datetime.strptime(until_date, '%m-%d-%Y')
    weekdays = map(int, weekdays)

    #Can probably use dateutils parser for this.
    if freq == "DAILY":
        freq=DAILY

    date_pairs = generate_date_pairs(freq, weekdays, start_date, until_date)

    result = list()

    for d in date_pairs:
        flight_scraper  =   FlightScraper(origin, dest, d[0], d[1])
        v = [d[0].isoformat(), d[1].isoformat(), flight_scraper.search_flights()]
        result.append(v)

    return render_template('query.html', result=result)
示例#3
0
def graph_flights():
    origin = request.args.get('origin')
    dest = request.args.get('dest')
    dept = request.args.get('dept')
    ret = request.args.get('ret')

    dept = datetime.strptime(dept, '%m-%d-%Y')
    ret = datetime.strptime(ret, '%m-%d-%Y')

    flight_scraper  =   FlightScraper(origin, dest, dept, ret)
#     flight_scraper.origin = origin
#     flight_scraper.destination = dest
#     flight_scraper.depart_date = dept
#     flight_scraper.return_date = ret

    solutions = flight_scraper.solutions()

    length = len(solutions)
    return render_template('graph.html', json_obj=graph_prices(flight_scraper), solutions=solutions, lengthSol=length)
示例#4
0
def graph_flights():
    origin = request.args.get('origin')
    dest = request.args.get('dest')
    dept = request.args.get('dept')
    ret = request.args.get('ret')

    dept = datetime.strptime(dept, '%m-%d-%Y')
    ret = datetime.strptime(ret, '%m-%d-%Y')

    flight_scraper  =   FlightScraper(origin, dest, dept, ret)
#     flight_scraper.origin = origin
#     flight_scraper.destination = dest
#     flight_scraper.depart_date = dept
#     flight_scraper.return_date = ret

    solutions = flight_scraper.solutions()

    length = len(solutions)
    return render_template('graph.html', json_obj=graph_prices(flight_scraper), solutions=solutions, lengthSol=length)
示例#5
0
def calendar_flight_query():
    origin = request.args.get('origin')
    dest = request.args.get('dest')
    start_date = request.args.get('start_date')
    until_date = request.args.get('until_date')
    airlines = request.args.get('airlines')
    day_range = request.args.get('length')
    max_stops = request.args.get('max_stops')

    if '-' in day_range:
        split = day_range.split('-')
        day_range = [int(s) for s in split]
    else:
        day_range = [int(day_range), int(day_range)]

    start_date = datetime.strptime(start_date, '%m-%d-%Y')
    until_date = datetime.strptime(until_date, '%m-%d-%Y')

    flight_scraper  =   FlightScraper(origin, dest, start_date, until_date, airlines=airlines, day_range=day_range, max_stops=max_stops)
    return render_template('calendar_query.html', result=flight_scraper.search_calendar())
示例#6
0
def calendar_flight_query():
    origin = request.args.get('origin')
    dest = request.args.get('dest')
    start_date = request.args.get('start_date')
    until_date = request.args.get('until_date')
    airlines = request.args.get('airlines')
    day_range = request.args.get('length')
    max_stops = request.args.get('max_stops')

    if '-' in day_range:
        split = day_range.split('-')
        day_range = [int(s) for s in split]
    else:
        day_range = [int(day_range), int(day_range)]

    start_date = datetime.strptime(start_date, '%m-%d-%Y')
    until_date = datetime.strptime(until_date, '%m-%d-%Y')

    flight_scraper  =   FlightScraper(origin, dest, start_date, until_date, airlines=airlines, day_range=day_range, max_stops=max_stops)
    return render_template('calendar_query.html', result=flight_scraper.search_calendar())