Я хочу скачать такой файл:
import urllib
link = 'http://ir.30nama.download/movies/t/The_Huntsman_Winters_War_2016_EXTENDED_Dubbed_1080p_BrRip_30nama_30NAMA.mkv?md5=E38HpAmjkzwU7Fpag-YvtA&expires=1529934194&refresh=4918368251152863819423374231251501'
filename = link[link.rfind('/') + 1:].split('?')[0]
response = urllib.URLopener()
response.addheader('User-Agent',
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11')
response.addheader('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')
response.addheader('Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.3')
response.addheader('Accept-Encoding', 'none')
response.addheader('Accept-Language', 'en-US,en;q=0.8')
response.addheader('Connection', 'keep-alive')
response.addheader('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')
response.retrieve(link, 'test.mkv')
Я добавил заголовки точно так же, как это post , но результат:
Traceback (most recent call last):
File "downloader.py", line 29, in <module>
response.retrieve(item['src_link'], consts.pdp_root + filename)
File "/usr/lib/python2.7/urllib.py", line 245, in retrieve
fp = self.open(url, data)
File "/usr/lib/python2.7/urllib.py", line 213, in open
return getattr(self, name)(url)
File "/usr/lib/python2.7/urllib.py", line 364, in open_http
return self.http_error(url, fp, errcode, errmsg, headers)
File "/usr/lib/python2.7/urllib.py", line 381, in http_error
return self.http_error_default(url, fp, errcode, errmsg, headers)
File "/usr/lib/python2.7/urllib.py", line 386, in http_error_default
raise IOError, ('http error', errcode, errmsg, headers)
IOError: ('http error', 403, 'Forbidden', <httplib.HTTPMessage instance at 0x7f98ec3d92d8>)
Что мне делать?