[Baypiggies] Any advice using HTTP REST in a Python client
doug at apley.com
Sun Jan 6 02:32:02 CET 2008
You might try the urllib2 library: http://docs.python.org/lib/module-urllib2.html
This library supports http, https, ftp, cookies, basic authentication,
put, post, head, etc.
Here is a quick example showing how you might use this. This is a
short program which downloads a copy of the FAA aircraft registration
database from the web. The database is in the form of a zipped file
on the FAA web site. This program doesn't do any error trapping as
you might want to, but it's been quietly plugging away since May (run
by a cron job) and never had any errors to trap.
Doug at Apley.com
# Doug at Apley.com 2007-05-23
import urllib2, os, time
# refer to http://www.faa.gov/licenses_certificates/aircraft_certification/aircraft_registry/releasable_aircraft_download/
# The URL contains the current year and month value. Strangely, you
can't retrieve older copies of the file just by using older year/month
# Also, the file is replaced several times a month and still lives at
the same URL.
if not os.path.isdir(local_aircraft_registration_archive):
f = urllib2.urlopen(aircraft_registration_url)
aircraft_registrations = f.read()
On Jan 5, 2008, at 5:38 PM, Robert Field wrote:
> Hi, All --
> I have a need to be able to upload and download files from a server
> a REST interface. The download would be by GET, the upload by PUT, I'm
> I'm not making too much headway on this and was wondering if anyone
> experience or knew of a tutorial resource.
> Baypiggies mailing list
> Baypiggies at python.org
> To change your subscription options or unsubscribe:
More information about the Baypiggies