Requests: A Painless HTTP Client for Python is brought to you in partnership with:

Mike is co-founder of Fiesta - https://fiesta.cc. Before Fiesta, he was a developer working on the MongoDB project. Mike is a DZone MVB and is not an employee of DZone and has posted 13 posts at DZone. You can read more from them at their website. View Full User Profile

Requests: A Painless HTTP Client for Python

11.21.2011
| 2920 views |
  • submit to reddit

I’ve always thought that making HTTP requests in Python was a lot harder than it should’ve been. Alone, the confusion between urllib and urllib2 is enough to drive me a little crazy. On top of that, neither library has that API je ne sais quoi, the “just works” feeling.

I think I’m way behind, here, but just yesterday I came across Requests, a library by Kenneth Reitz. Here’s the first example from the documentation:

>>> r = requests.get('https://api.github.com', auth=('user', 'pass'))
>>> r.status_code
204
>>> r.headers['content-type']
'application/json'

This looks much better than what I’m used to. I think we’ll start using Requests when we need an HTTP client for Fiesta. Does anybody have any experience (good or bad) with it? Is there some other library we should be taking a look at as well, once we’ve committed to moving on from the stdlib?

Mike


source: http://blog.fiesta.cc/post/11139748502/requests-a-painless-http-client-for-python

Published at DZone with permission of Mike Dirolf, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)