2017-06-29 49 views
0

這是正在使用的代碼未找到:HTTP錯誤404:使用wget時,下載鏈接

import wget 

firefox_29 = "https://ftp.mozilla.org/pub/firefox/releases/29.0.1/win32/en- 
US/Firefox%20Setup%2029.0.1.exe" 

firefox_dir = 'C:\\firefox\\firefox29' 

wget.download(firefox_29, out=firefox_dir) 

這是我的錯誤,我以前用同樣的方式使用wget和它的工作好,所以我很困惑,爲什麼會出現這個錯誤。此外,鏈接是一個工作鏈接。

enter image description here

+0

檢查您的URL。如果它是404,它可能來自它。 –

+0

該網址的作品,如果我點擊它,它會下載。 –

回答

0

我設法弄清楚不使用wget。顯然wget只是urllib的包裝。所以我使用了urlretrieve。繼承人的代碼:

import urllib.request 

firefox_29 = "https://ftp.mozilla.org/pub/firefox/releases/29.0.1/win32/en- 
US/Firefox%20Setup%2029.0.1.exe" 

urllib.request.urlretrieve(firefox_29, 'firefox29.exe') 

然而,這只是重命名.exe文件以「firefox29.exe」,所以如果你需要將其下載到特定的位置,你只需要它自己移動。