```python import urllib2 req = urllib2.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']='bytes=%s-%s' % (18000, 19000) f = urllib2.urlopen(req) # This shows you the actual bytes that have been downloaded. content_range=f.headers.get('Content-Range') print(content_range) # bytes 18000-18030/18031 ```
Jul 2, 9:35am
Here’s the updated script for Python 3, using the urllib.request module instead of the deprecated urllib2:
python
import 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
Jul 2, 9:35am
This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.