Here’s the updated script for Python 3, using the urllib.request module instead of the deprecated urllib2:
pythonimport urllib.request req = urllib.request.Request('http://www.python.org/') # Here we request that bytes 18000--19000 be downloaded. # The range is inclusive, and starts at 0. req.headers['Range'] = f'bytes={18000}-{19000}' with urllib.request.urlopen(req) as f: # This shows you the actual bytes that have been downloaded. content_range = f.headers.get('Content-Range') print(content_range) # bytes 18000-18030/18031
Vibe can make mistakes. Check answers. Learn more