如何使用命令行下载 zip 文件

如何使用命令行下载 zip 文件

我想从 dropbox 或 UCF-Crime 视频数据集下载一个高度压缩的 zip 文件。数据集的网站指出这两个链接可以从中获取数据集:

每次我尝试通过 wget 或 curl 下载数据集时都会失败。我知道我尝试的方法不对。我的示例将 visionlab url 作为参数。

wget https://visionlab.uncc.edu/download/summary/60-data/477-ucf-anomaly-detection-dataset/UCF-Anomaly-Detection-Dataset.zip

或者

curl https://visionlab.uncc.edu/download/summary/60-data/477-ucf-anomaly-detection-dataset/UCF-Anomaly-Detection-Dataset.zip

每次尝试时,我都会遇到此错误消息:

ERROR: cannot verify visionlab.uncc.edu's certificate, issued by ...
Unable to locally verify the issuer's authority.
To connect to visionlab.uncc.edu insecurely, use `--no-check-certificate'.

编辑:我尝试通过启用该--no-check-certificate选项来下载数据集。但是,我收到以下消息:

wget --no-check-certificate https://visionlab.uncc.edu/download/summary/60-data/477-ucf-anomaly-detection-dataset/UCF-Anomaly-Detection-Dataset.zip
--2020-12-10 13:58:23--  https://visionlab.uncc.edu/download/summary/60-data/477-ucf-anomaly-detection-dataset/UCF-Anomaly-Detection-Dataset.zip
Resolving visionlab.uncc.edu (visionlab.uncc.edu)... 
WARNING: cannot verify visionlab.uncc.edu's certificate, issued by ...:
  Unable to locally verify the issuer's authority.
HTTP request sent, awaiting response... 404 Not Found
2020-12-10 13:58:24 ERROR 404: Not Found.

答案1

当您访问Dropbox 链接,您将找到可供 wget 使用的链接。我尝试了第一个:

wget https://www.dropbox.com/sh/75v5ehq4cdg5g5g/AABvnJSwZI7zXb8_myBA0CLHa?dl=0

此外,您可能需要更新本地证书:

update-ca-certificates -f

答案2

我没有找到直接解决问题的办法,但我实施了一种可以解决 Dropbox 链接问题的变通方法。在朋友的帮助下,我可以提取每个 Dropbox 文件的下载链接。

我把这些 URL 链接放在一个文本文件中UCF-Crime_download_links.txt

Anomaly_Train.txt,https://ucfd47a3132502df8b7da1078048.dl.dropboxusercontent.com/cd/0/get/BFD94aIgIcZePmQnMUR9GXKvwiKLuWkTXQlJUbrCIcuOtEbnrhq0WYHD3_tE6VNIutXB-0uuD4KSnGT_XbbcYKRGo33iS5p2_MNLZ0cMGqAttw/file?_download_id=097716663047956452461729849578513492367789635489118937591573887371&_notify_domain=www.dropbox.com&dl=1
Anomaly-Videos-Part-1.zip,https://ucd2b23b12c729fc4c377d2a4559.dl.dropboxusercontent.com/cd/0/get/BFDZ8seM8pKTbOBVnx8XejXk_oJHQXEQsSoGomJSLcmrwaToJjaDPhGe4i7WDKQdzVKcRbd3LhpTFXfaKq-HLvM77kg10eGbzj39azmYeecEYQ/file?_download_id=0363965750577266464342348679706188869134262358521904742084241846&_notify_domain=www.dropbox.com&dl=1
Anomaly-Videos-Part-2.zip,https://uc2bed7c7a17a15220b13be4a2e6.dl.dropboxusercontent.com/cd/0/get/BFBSk-HeNvTfjVihchn8wJ4ZARgFpfsvx0xI_wPyfnByA0Jont0INM_M8FEzSUUzOYRKA1WLJ1CY5cFHZD4KJasNIhQWPCEY33OL1WR40lmd3g/file?_download_id=0579378818307589862973462645032838382079214641391144587467813138293&_notify_domain=www.dropbox.com&dl=1
Anomaly-Videos-Part-3.zip,https://uc92f1b103a1be39f95efe1c6144.dl.dropboxusercontent.com/cd/0/get/BFCfynAnLeJI_qWCDNlqunMW5MOov14OQnZRHuexd-GZJrstjFdpu5BAf8IUxGMOUWJNz1FPDni-fE1YABI13LOXLQoQYmli-kRHrOaF1ImjYg/file?_download_id=727024674397661849253116806809373576342610272509334976130541060124&_notify_domain=www.dropbox.com&dl=1
Anomaly-Videos-Part-4.zip,https://uc0c9ade9be14edadc6215823861.dl.dropboxusercontent.com/cd/0/get/BFDjzs0TcEM_xsCnb6X_43Q4Nzhr4yB5ccPcKusL9TGDgeCVVuahZ0rT5S_0PiMDRh5HvzkJ3INGEXKrednLF-ZFtKxDHSDyktHOheNo6Cr4JQ/file?_download_id=55589026333033841043625854492820157750952578262247539791205866326&_notify_domain=www.dropbox.com&dl=1
Normal_Videos_for_Event_Recognition.zip,https://uc0c2c5bfde8f04a8f545a0f7c48.dl.dropboxusercontent.com/cd/0/get/BFDzshYfN81gu1bweDMKjubBmNuyVNGI4srsoXyFXB3yNYN39mi5MZWiCYk9RQ97-ntZLzV97zNefXDs3N-16rb4IYH0eZHLvR2F15ePudQjGw/file?_download_id=754017652375024472883071931908466187771437616567601330606754946&_notify_domain=www.dropbox.com&dl=1
ReadMe-Anomaly-Detection.txt,https://uc2ae171f6610223bc44b0571a06.dl.dropboxusercontent.com/cd/0/get/BFAExBD5DyYH3mIUFFwlh0AXQJ1zNBhlria77CyD5EKAr29aJTLYOV0-67iPv993peIgTl6bmV1TLcYVjypvLlABdlr_supYpWNlaJif71H1xw/file?_download_id=987765206572950519523413130201916364276953226782661290955905419846&_notify_domain=www.dropbox.com&dl=1
Temporal_Anomaly_Annotation_for_Testing_Videos.txt,https://uc1b4ac9977c9671dcd4d9e7769f.dl.dropboxusercontent.com/cd/0/get/BFAUo61sFDlmJO2jH1k-lg9PkyuMgB-ra363o6l5zS7d5UmCn7zdDB224a86DfNX-oqQk1gdefwZFMHOK2_wvJP2FvJuL8Ft_eFYdvh7Ez9JrA/file?_download_id=51676525513664041950873962382331226008355206984435667655330876461&_notify_domain=www.dropbox.com&dl=1
Testing_Normal_Videos.zip,https://uc4726690c34a81dd2daf9b07b6e.dl.dropboxusercontent.com/cd/0/get/BFDkHyWEpPY-ujMPqFW1jCt6-1N0tFH0dkHE13Zx-DMbM-9OyVbsAVaxAQX322yYGRWGelhHBLYVjOEYa8VJiI_Bx3eiwzKPjQAEWjT5OFbhAg/file?_download_id=570733229890446284890063923590291221261415804728635013945386341994&_notify_domain=www.dropbox.com&dl=1
Training-Normal-Videos-Part-1.zip,https://ucc4a7ebb4b9f43444740e1bf130.dl.dropboxusercontent.com/cd/0/get/BFAXVtO9deicS-czConfc8qyFh7EY4Mdw97L35u8jB-fUXDMFCC0fJGrh2cUw_daJ44eR4wEIkmm9ADPC5thIZ2aOyJTXTuiJ8O_72F-dqZVjA/file?_download_id=48412181900856838492867675657194829029734593236333792964919684665&_notify_domain=www.dropbox.com&dl=1
Training-Normal-Videos-Part-2.zip,https://uc924337e0d8e7a24323eb0e7174.dl.dropboxusercontent.com/cd/0/get/BFAw_Eym3ICikx0fA_-PSyihqzNXQqJfVVfzCanJa0aoVIF84U644oKm2Kd7ZuUrUwSlfRxrCTsr8Sb1pGLKb485GaKnBCV49NYuyssjT4xSRw/file?_download_id=655411935603899202237191315622855477671008665861545359350399844076&_notify_domain=www.dropbox.com&dl=1
UCF_Crimes-Train-Test-Split.zip,https://uc2807770edb067ebc8f6751f4d0.dl.dropboxusercontent.com/cd/0/get/BFAxnOoeRrGLmch7uOB6U_W7bVF00uUsAuHU-MZmNUz7CXMjXZuCk-TOUMyzus23bC83gltkAeMaiW7rQ7pS7gOl-Rf8zN6dvrx7yFDrGkt1LA/file?_download_id=221324488118949561849144925330559290896952119513818184423550876863&_notify_domain=www.dropbox.com&dl=1

您可以通过按照以下步骤尝试下载每个文件来获取这些链接:

在此处输入图片描述

在此处输入图片描述

然后我执行了这个 Python 代码download_ucf-crime.py来下载它们每一个:

import os

filepath = "UCF-Crime_download_links.txt"
file = open(filepath,"r")
lines = file.readlines()
for line in lines:
    line_parts = line.split(',')
    link_filename = line_parts[0]
    link_url = line_parts[1]
    os.system('wget -O %s %s'%(link_filename,link_url))
file.close()

我的朋友建议我检查 dropbox API 以获得更干净的解决方案:https://github.com/dropbox/dropbox-sdk-python

相关内容