import urllib2 import httplib httplib.HTTP._http_vsn_str = 'HTTP/1.1' uri = 'http://blogs.msdn.com/MainFeed.aspx' # uri= 'http://www.cincomsmalltalk.com/BottomFeeder/index.html' request = urllib2.Request(uri) request.add_header("Accept-encoding", "gzip, deflate") result = urllib2.urlopen(request) headers = result.info() etag = headers.getheader("ETag") last_modified = headers.getheader("Last-Modified") print "Content-Encoding:", headers.get('Content-Encoding') request = urllib2.Request(uri) if etag: request.add_header("If-None-Match", etag) if last_modified: request.add_header("If-Modified-Since", last_modified) try: result = urllib2.urlopen(request) print "no Error" except urllib2.HTTPError, error: print error