Woman Tochka
Woman Tochka

Reputation: 21

python requests library - get part of response

How can i get a part of response of get/post-request from python-requests library? I need get URL content and analys it fast, but web-server may return a very large response (500Mb for example).

Upvotes: 0

Views: 158

Answers (1)

lord63. j
lord63. j

Reputation: 4670

Set stream to True.

example_url = 'http://www.example.com/somethingbig'
r = requests.get(example_url, stream=True)

At this point only the response headers have been downloaded and the connection remains open.

Documentation: body-content-workflow

Upvotes: 2

Related Questions