Wednesday, May 9, 2012

Flight tracking

As I prepare to head to Bielefeld for summer research, a young woman's fancy turns lightly to the thought of getting the lowest airfare possible. How long should I wait? I've heard that at 21 days out, prices start dropping as airlines try to fill seats. I've been looking for my ticket for a while, and so far I've seen no evidence of a significant change either way around 21 days. I more rigorously searched fares manually one day and noticed that a quite significant drop may actually occur around day 14. But that seems like it's cutting it awfully close...How can I be sure? Was that one day just a fluke?

Step 1: Search Expedia automatically for the lowest fare available for my point-of-origin/destination starting with 1 day out (tomorrow) up until my actual day of departure (the 28th). Wow, that's only 19 days. I'm cutting it close regardless... (Don't worry, while my evidence on the 14-day drop is equivocal, I've seen no evidence whatsoever that the last-minute price rise occurs before 7 days out, and most likely occurs about 3 or 4 days out.)

#!/usr/bin/python                                                                                          

import os

departuremonth="05"

i=9
while (i<=28) :
    departureday=str(i)

    cmd = 'curl http://www.expedia.com/Flights-Search?trip=roundtrip\&leg1=from:Indianapolis,%20IN,%20Unite\
d%20States%20%28IND-Indianapolis%20Intl.%29,to:Frankfurt,%20Germany%20%28FRA-All%20Airports%29,departure:'+\
departuremonth+'%2F'+departureday+'%2F2012TANYT\&leg2=from:Frankfurt,%20Germany%20%28FRA-All%20Airports%29,\
to:Indianapolis,%20IN,%20United%20States%20%28IND-Indianapolis%20Intl.%29,departure:08%2F03%2F2012TANYT\&pa\
ssengers=children:0,adults:1,seniors:0,infantinlap:Y\&options=cabinclass:coach,nopenalty:N,sortby:price\&mo\
de=search > relly3'

    os.system(cmd)

    resultsfile = file("relly3",'r')
    lines = resultsfile.readlines()
    for line in lines:
        if line.find("formattedLowestPrice")!=-1:
            removeKey="formattedLowestPrice\">"
            removefrom=line.find(removeKey)+len(removeKey)
            line=line[removefrom:]
            removeto=line.find("<")
            line=line[:removeto]
            print departuremonth+"-"+departureday+"-12: " + line

    i+=1

No comments:

Post a Comment