|
I have many links to download, but many of them is not of desired content type. i.e. I'm just interested in |
Answered by
johtso
Jun 29, 2021
Replies: 1 comment
|
You could just make your requests in streaming mode and not read the content. https://www.python-httpx.org/quickstart/#streaming-responses The last example in that section of the docs is basically your use case: >>> with httpx.stream("GET", "https://www.example.com") as r:
... if r.headers['Content-Length'] < TOO_LONG:
... r.read()
... print(r.text) |
0 replies
Answer selected by
lovelydinosaur
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could just make your requests in streaming mode and not read the content. https://www.python-httpx.org/quickstart/#streaming-responses
The last example in that section of the docs is basically your use case: