Screen scraping flight data from Amadeus let’s you input an airplane flight booking reference and your surname in return for a flight itinerary. This is useful for building all sorts of services to travellers. Unfortunately Amadeus doesn’t have an API, nor are their url’s restful. Using Python, mechanize, htm5lib and BeautifulSoup, you can get at the data pretty easy though.

It is somewhat unclear whether Amadeus approve of people scraping their site, related debate here (check the comments).

I’m not a very good Python programmer (yet!) and the script below could probably be improved quite a lot:

import re
import mechanize
import html5lib
from BeautifulSoup import BeautifulSoup

br = mechanize.Browser()
re1 ="")
re2 = br.submit()
html =
doc = html5lib.parse(html)
soup =  BeautifulSoup(doc.toxml())
flightdivs = soup.findAll('div', { "class" : "divtableFlightConf" } )
for div in flightdivs:
    table = div.table
    daterow = table.findChildren("tr")[2]
    datecell = daterow.findChildren("td")[1].string.lstrip().rstrip()
    maincell = table.findChildren("tr")[3]
    timetable = maincell.table.findChildren("tr")[0].td.table
    times =  timetable.findAll("td", {"class" : "nowrap"})
    dtime = times[0].string.lstrip().rstrip()
    atime = times[1].string.lstrip().rstrip()
    airports = timetable.findAll("input", {"name" : "AIRPORT_CODE"})
    aairport = airports[0]['value'].lstrip().rstrip()
    dairport = airports[1]['value'].lstrip().rstrip()
    flight = table.findAll("td", {"id" : "segAirline_0_0"})[0].string.lstrip().rstrip()
    print '--'    
    print 'date: ' + datecell
    print 'departuretime: ' + dtime
    print 'arrivaltime: ' + atime
    print 'departureairport: ' + dairport    
    print 'arrivalairport: ' + aairport
    print 'flight: ' + flight

3 thoughts on “Screen scraping flight data from Amadeus”

  • Not only that, this is a great system to let off the airline industry when they screw up. We got e-mailed one itinerary and the agent booked something else.. when we checked “check my trip” the booking didn’t show up or the web browser wouldn’t open the site. Therefore we trusted the e-ticket.. arrived at the airport to find out that we were in fact not on the flight bought on the e ticket. big problem as we missed our flights and got charged an additional $800 and we had no way of knowing either.. The airlines can rely on “check my trip” to opt out of a mistake. Easy.. Travellers beware of “Amadeus check my trip”

  • The travel company was we don’t know what data was entered where, Amadeus check my trip works great for sell off vacations as they can fall back on this site.. and once they set you up a reference number that number can apply to the trip you set up and any other trip. that means that this reference number is assigned to you not the trip. This is how the mistake got made. The Travel agency booked us on different flights than the e-mail confirmation we got. Check my trip might have been correct but we have no way of knowing at this point as when we were billed the additional $800 the reference number doesn’t indicate show the previous booking at all. Nice system for travel companies that don’t want to be responsible..

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>