3

How do I take advantage of HTTP 1.1's compression when downloading web pages using Python?

I am currently using the built-in urllib module for downloading web content. Reading through the documentation I couldn't find any information that is indeed using compression.

Is it already built-in into urllib or is there another library that I can use?

1 Answer 1

6

httplib2 supports 'deflate' and 'gzip' compression.

Example

import httplib2
h = httplib2.Http(".cache")
resp, content = h.request("http://example.org/", "GET")

The content is decompressed as necessary.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.