我正在嘗試從https://www.fec.gov/data/browse-data/?tab=bulk-data下載 .zip 文件,特別是https://www.fec.gov/files/bulk-downloads/2020 /indiv20.zip。壓縮后,文件大小為 2.7 GB。下載將在 10 秒內(nèi)啟動(dòng)并完成。當(dāng)我嘗試解壓縮該文件時(shí),我收到以下錯(cuò)誤消息。下載到我的本地計(jì)算機(jī)時(shí),鏈接會(huì)以 .zip 文件形式下載并打開(kāi)所需的數(shù)據(jù)。!python --versionPython 3.7.8!curl -O https://www.fec.gov/files/bulk-downloads/2020/indiv20.zip % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 138 100 138 0 0 690 0 --:--:-- --:--:-- --:--:-- 690!unzip -a indiv20.zipArchive: indiv20.zip End-of-central-directory signature not found. Either this file is not a zipfile, or it constitutes one disk of a multi-part archive. In the latter case the central directory and zipfile comment will be found on the last disk(s) of this archive. unzip: cannot find zipfile directory in one of indiv20.zip or indiv20.zip.zip, and cannot find indiv20.zip.ZIP, period. import zipfilewith zipfile.ZipFile("indiv20.zip", 'r') as zip_ref: zip_ref.extractall()
2 回答

HUX布斯
TA貢獻(xiàn)1876條經(jīng)驗(yàn) 獲得超6個(gè)贊
看起來(lái) HTTP 服務(wù)器正在返回重定向,并將curl
“302 Found”消息存儲(chǔ)到 indiv20.zip 文件中,而不是實(shí)際的 ZIP 數(shù)據(jù)中。
您可以通過(guò)在命令中添加-L
(或--location)參數(shù)來(lái)解決此問(wèn)題curl
,以便它遵循重定向:
$?curl?-LO?https://www.fec.gov/files/bulk-downloads/2020/indiv20.zip
添加回答
舉報(bào)
0/150
提交
取消