demo_requests_response_iter_lines.py:
import requests url = 'https://www.begtut.com/python/demopage.htm' x = requests.get(url) #return an iterator, one item for each line: print(x.iter_lines()) #looping through the iterator: for c in x.iter_content(): print(c)
➜ begtut>python demo_requests_response_iter_lines.py
b'<!DOCTYPE html>'
b'<html>'
b'<body>'
b''
b'<h1>This is a Test Page</h1>'
b''
b'</body>'
b'</html>'