Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Requests: A Painless HTTP Client for Python

DZone's Guide to

Requests: A Painless HTTP Client for Python

· Web Dev Zone
Free Resource

Never build auth again! Okta makes it simple to implement authentication, authorization, MFA and more in minutes. Try the free developer API today! 

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

Launch your application faster with Okta’s user management API. Register today for the free forever developer edition!

Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}