python: urllib.request.urlopen() HTTP 错误 308 永久重定向
python: urllib.request.urlopen() HTTP Error 308 Permanent redirect
我只是想从互联网上读取一个文件..
然后就报错了..
Traceback (most recent call last):
File "E:\Sapphire\Programming\download_file.py", line 46, in <module>
download(arg[1])
File "E:\Sapphire\Programming\download_file.py", line 19, in download
file_info = req.urlopen("http://proget.whirlpool.repl.co/{}/{}.txt".format(arch, name))
File "E:\Programming\Python38-32\lib\urllib\request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "E:\Programming\Python38-32\lib\urllib\request.py", line 531, in open
response = meth(req, response)
File "E:\Programming\Python38-32\lib\urllib\request.py", line 640, in http_response
response = self.parent.error(
File "E:\Programming\Python38-32\lib\urllib\request.py", line 569, in error
return self._call_chain(*args)
File "E:\Programming\Python38-32\lib\urllib\request.py", line 502, in _call_chain
result = func(*args)
File "E:\Programming\Python38-32\lib\urllib\request.py", line 649, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 308: Permanent Redirect
导致错误的行(第 20 行):
file_info = req.urlopen("http://proget.whirlpool.repl.co/{}/{}.txt".format(arch, name))
(它应该使用的link是正确的..)
有什么想法吗?
SPECS:
OS: Windows 7 SP1
Python: Python 3.8.10
Arch: x86 (32-bit)
Http 已过时,因此大多数网站将重定向到 https。
所以使用
file_info = req.urlopen("https://proget.whirlpool.repl.co/{}/{}.txt".format(arch, name))
我只是想从互联网上读取一个文件.. 然后就报错了..
Traceback (most recent call last):
File "E:\Sapphire\Programming\download_file.py", line 46, in <module>
download(arg[1])
File "E:\Sapphire\Programming\download_file.py", line 19, in download
file_info = req.urlopen("http://proget.whirlpool.repl.co/{}/{}.txt".format(arch, name))
File "E:\Programming\Python38-32\lib\urllib\request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "E:\Programming\Python38-32\lib\urllib\request.py", line 531, in open
response = meth(req, response)
File "E:\Programming\Python38-32\lib\urllib\request.py", line 640, in http_response
response = self.parent.error(
File "E:\Programming\Python38-32\lib\urllib\request.py", line 569, in error
return self._call_chain(*args)
File "E:\Programming\Python38-32\lib\urllib\request.py", line 502, in _call_chain
result = func(*args)
File "E:\Programming\Python38-32\lib\urllib\request.py", line 649, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 308: Permanent Redirect
导致错误的行(第 20 行):
file_info = req.urlopen("http://proget.whirlpool.repl.co/{}/{}.txt".format(arch, name))
(它应该使用的link是正确的..) 有什么想法吗?
SPECS:
OS: Windows 7 SP1
Python: Python 3.8.10
Arch: x86 (32-bit)
Http 已过时,因此大多数网站将重定向到 https。
所以使用
file_info = req.urlopen("https://proget.whirlpool.repl.co/{}/{}.txt".format(arch, name))