Exemplo n.º 1
0
def bidirectional_search(origin, dest, until_date):
    """ Sample Script for automation."""

    #Initialize FlightScraper
    flight_scraper = FlightScraper()

    MO, TU, WE, TH, FR, SA, SU = tuple(range(7))

    #Dates to search
    weekdays_1 = (FR,SU)
    weekdays_2 = (FR,MO)
    start_date = __get_start_date()

    #Generates depart_date & return_date pairs in that order from start_date to util_date
    date_pairs_1 = generate_date_pairs(DAILY, weekdays_1, start_date, until_date)
    date_pairs_2 = generate_date_pairs(DAILY, weekdays_2, start_date, until_date)

    #Search 1
    for d in date_pairs_1:
        flight_scraper.origin = origin
        flight_scraper.destination = dest
        flight_scraper.depart_date = d[0]
        flight_scraper.return_date = d[1]

        flight_scraper.search_flights()

    #Search 2
    for d in date_pairs_2:
        flight_scraper.origin = dest
        flight_scraper.destination = origin
        flight_scraper.depart_date = d[0]
        flight_scraper.return_date = d[1]

        flight_scraper.search_flights()
Exemplo n.º 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)
Exemplo n.º 3
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)
Exemplo n.º 4
0
def bidirectional_search(origin, dest, until_date):
    """ Sample Script for automation."""

    #Initialize FlightScraper
    flight_scraper = FlightScraper()

    MO, TU, WE, TH, FR, SA, SU = tuple(range(7))

    #Dates to search
    weekdays_1 = (FR, SU)
    weekdays_2 = (FR, MO)
    start_date = __get_start_date()

    #Generates depart_date & return_date pairs in that order from start_date to util_date
    date_pairs_1 = generate_date_pairs(DAILY, weekdays_1, start_date,
                                       until_date)
    date_pairs_2 = generate_date_pairs(DAILY, weekdays_2, start_date,
                                       until_date)

    #Search 1
    for d in date_pairs_1:
        flight_scraper.origin = origin
        flight_scraper.destination = dest
        flight_scraper.depart_date = d[0]
        flight_scraper.return_date = d[1]

        flight_scraper.search_flights()

    #Search 2
    for d in date_pairs_2:
        flight_scraper.origin = dest
        flight_scraper.destination = origin
        flight_scraper.depart_date = d[0]
        flight_scraper.return_date = d[1]

        flight_scraper.search_flights()
Exemplo n.º 5
0
def graph_weekly():
    origin = request.args.get('origin')
    dest = request.args.get('dest')
    dept = request.args.get('dept')
    ret = request.args.get('ret')

    start_date = datetime.strptime("1-1-2013", '%m-%d-%Y')
    until_date = datetime.strptime("12-31-2013", '%m-%d-%Y')
    weekdays = map(int, [4,6])

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

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

    for d in date_pairs:
        flight_scraper.depart_date = d[0]
        flight_scraper.return_date = d[1]
        result.append(graph_prices(flight_scraper))

    return render_template('graph_weekly.html', graphs=result, length=len(result))
Exemplo n.º 6
0
def graph_weekly():
    origin = request.args.get('origin')
    dest = request.args.get('dest')
    dept = request.args.get('dept')
    ret = request.args.get('ret')

    start_date = datetime.strptime("1-1-2013", '%m-%d-%Y')
    until_date = datetime.strptime("12-31-2013", '%m-%d-%Y')
    weekdays = map(int, [4,6])

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

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

    for d in date_pairs:
        flight_scraper.depart_date = d[0]
        flight_scraper.return_date = d[1]
        result.append(graph_prices(flight_scraper))

    return render_template('graph_weekly.html', graphs=result, length=len(result))