When a user does a flight search on Hipmunk, they send requests to a bunch of dataproviders who have the actual flight data. Hipmunk takes the user’s flight search andsends it to ITA, sends it to one or more airlines, and in some cases they'll even send itto Amtrak, if that's appropriate. Each of these organisations are companies who havetheir own services that Hipmunk works with. ITA will run the flight search, and sendthe results back. The Airline will also run the flight search on their own system andsend their results back. Similarly, Amtrak does its thing and send their data back toHipmunk. So, now Hipmunk has all this flight search data on their server. They thenmanipulate that data, collate it, make you nice results, and then we'll send back theirHTML response to the user (or ‘customer’ in this case – since they’re paying!).So, this unit is about how to make our servers speak to other servers when there's nobrowser involved. We’ll still use HTTP, but we are now communicating over otherprotocols. We saw some of this in Unit 1, but we'll be doing a lot more in this lesson,because there's so much you can do when you realize that you're not the only serviceon the internet.
urllib
First, let’s introduce a Python library for actually making an HTTP requests so we cansee how that worksPython has a library calledurllib2. There's also a library called justurllib(referred to
as “urlib1”), which does have a few handy functions of its own. However, we're goingto use urllib2 for the most part.