demo_requests_response_iter_content.py:
import requests url = 'https://www.begtut.com/python/demopage.htm' x = requests.get(url) #return an iterator, one item for each character: print(x.iter_content()) #looping through the iterator: for c in x.iter_content(): print(c)
➜ begtut>python demo_requests_response_iter_content.py
b'<'
b'!'
b'D'
b'O'
b'C'
b'T'
b'Y'
b'P'
b'E'
b' '
b'h'
b't'
b'm'
b'l'
b'>'
b'\r'
b'\n'
b'<'
b'h'
b't'
b'm'
b'l'
b'>'
b'\r'
b'\n'
b'<'
b'b'
b'o'
b'd'
b'y'
b'>'
b'\r'
b'\n'
b'\r'
b'\n'
b'<'
b'h'
b'1'
b'>'
b'T'
b'h'
b'i'
b's'
b' '
b'i'
b's'
b' '
b'a'
b' '
b'T'
b'e'
b's'
b't'
b' '
b'P'
b'a'
b'g'
b'e'
b'<'
b'/'
b'h'
b'1'
b'>'
b'\r'
b'\n'
b'\r'
b'\n'
b'<'
b'/'
b'b'
b'o'
b'd'
b'y'
b'>'
b'\r'
b'\n'
b'<'
b'/'
b'h'
b't'
b'm'
b'l'
b'>'