wget 下載不了的檔案,因為需要cookie.txt,用curl命令下載
https://www.kaggle.com/c/avito-context-ad-clicks/data
kaggle上面連結的資料,直接用wget命令是下載不了的。
wget https://www.kaggle.com/c/avito-context-ad-clicks/data命令會被拒絕。
http://askubuntu.com/questions/161778/how-do-i-use-wget-curl-to-download-from-a-site-i-am-logged-into該部落格上講述了各種解決方案,其實最關鍵的還是要cookie.txt.
解決方案用curl命令下載該檔案。
chrome 可以生成curl命令:
步驟:
比如要下載:Userinfo.tsv檔案
第一步:到該下載按鈕下,右鍵點選檢查。切換到Network選項。
第二步:點選該下載按鈕,chrome就會自動幫我們監控。
出現了兩個UserInfo.tsv.7z
第三步:右鍵點選Copyan cURL.(bash)
然後將該命令複製到ubuntu上執行,就可以下載檔案了
curl 'https://kaggle2.blob.core.windows.net/competitions-data/kaggle/4438/UserInfo.tsv.7z?sv=2012-02-12&se=2015-12-10T16%3A26%3A05Z&sr=b&sp=r&sig=olOI7lwDgKKXFFYmpYXalphxKjFfDa5uQ5w7rIcMQGo%3D'-H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: zh-CN,zh;q=0.8'-H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1;WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73Safari/537.36' -H 'Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H'Referer: https://www.kaggle.com/c/avito-context-ad-clicks/data' -H'Connection: keep-alive' --compressed
預設是輸出到標準輸出的
curl'https://kaggle2.blob.core.windows.net/competitions-data/kaggle/4438/UserInfo.tsv.7z?sv=2012-02-12&se=2015-12-10T16%3A26%3A05Z&sr=b&sp=r&sig=olOI7lwDgKKXFFYmpYXalphxKjFfDa5uQ5w7rIcMQGo%3D'-H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: zh-CN,zh;q=0.8'-H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1;WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73Safari/537.36' -H 'Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H'Referer: https://www.kaggle.com/c/avito-context-ad-clicks/data' -H'Connection: keep-alive' --compressed -o 1.7z 重定向到1.7z