Measurement of the energy spectrum of cosmic rays using the Pierre Auger Observatory