簡體   English   中英

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))

(它應該使用的鏈接是正確的..)有什么想法嗎?

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))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM