requests
01 Dec 2016Getting your program to make simple HTTP has become a feature that is just a given these days. The python library requests makes life a lot easier.
Requests is the only Non-GMO HTTP library for Python, safe for human consumption.
Today’s post will focus on this library, to show you how you can be immediately productive.
How things were
One of the best comparisons comes directly from the requests documentation. Prior to its existence, you needed to do the following to perform a GET
request with Basic Authentication:
Bringing this code forward to use the requests library, the code simplifies:
Clearly, you can see that the code using the requests library is far simpler. Let’s look at some more examples.
Simple verbs
The simple verbs can be used quite simply by name:
Of course the likes of OPTIONS
and HEAD
are also available.
Finishing up
The rest of this blog post could easily replicate all of the content in the documentation, but instead I’ll link to all of the good stuff: