Binary response content, requests lib
<p>I was reading the documentation on the requests lib and it seems to be tremendously outdated or something.</p>
<p>I was going step by step, trying all the examples shown there and encountered a problem as I tried running the following piece:</p>
<pre class="lang-py prettyprint-override"><code>import requests
from PIL import Image
from StringIO import StringIO

response = requests.get('http://www.github.com')
i = Image.open(StringIO(response.content))
</code></pre>
<p>That piece is from the official documentation. The first error that I got was the <code>ImportError: no module named StringIO</code></p>
<p>Okay, then I found out that that module no longer exists, and in order to import StringIO one has to write <code>from io import StringIO</code>. I did that. Tried running the code again and this time it errored out with <code>TypeError:initial_value must be str or None, not bytes</code>.
What on earth did I do wrong? I don't follow...All I did was try running the code from the official doc....I'm clueless.</p>
<p>EDITED:
And yeah...to use PIL one has to install Pillow.</p>