What exactly does iter_content() function do?
<p>just finished learning web scraping from automate the boring stuff book, but i'm still really confused about iter_content function? what does it actually do?</p>

<p>try to download web page using normal:  </p>

<pre><code>note = open('download.txt', 'w')
note.write(request)
note.close()
</code></pre>

<p>but the result is different from using:</p>

<pre><code>note = open('download.txt', 'wb')
for chunk in request.iter_content(100000):
    note.write(chunk)
note.close()
</code></pre>

<p>???</p>

<p><strong><em>iter_content</em></strong>(<em>chunk_size=1, decode_unicode=False</em>)</p>

<p>Iterates over the response data. When stream=True is set on the request, this avoids reading the content at once into memory for large responses. The chunk size is the number of bytes it should read into memory. This is not necessarily the length of each item returned as decoding can take place.</p>

<p>chunk_size must be of type int or None. A value of None will function differently depending on the value of stream. stream=True will read data as it arrives in whatever size the chunks are received. If stream=False, data is returned as a single chunk.</p>

<p>If decode_unicode is True, content will be decoded using the best available encoding based on the response.</p>

<p>link - <a href="http://docs.python-requests.org/en/master/api/" rel="nofollow">http://docs.python-requests.org/en/master/api/</a></p>

<p><em>here in this case it will iterate over the response with 100000 bytes each time</em></p>

python python-3.x