2016-11-01 3 views
4

Я пишу сценарий, который должен скачать файл выпуска из sourceforge. Как получить хорошую ссылку?Как загрузить файл из SourceForge с помощью wget?

Тот же вопрос и его ответ были даны здесь в 2013 году, но он больше не работает. https://unix.stackexchange.com/questions/86971/how-do-i-download-from-sourceforge-with-wget

$ wget 'http://downloads.sourceforge.net/project/romfs/genromfs/0.5.2/genromfs-0.5.2.tar.gz' 
Saving to: ‘download?use_mirror=vorboss.html’ 

Update: журнал следующий ответ @ vookimedlo в:

$ ls -ld $(which wget) 
lrwxr-xr-x 1 david admin 30 Mar 29 16:17 /usr/local/bin/wget -> ../Cellar/wget/1.19.1/bin/wget 

$ wget --version 
GNU Wget 1.19.1 built on darwin16.4.0. 

-cares +digest -gpgme +https +ipv6 -iri +large-file -metalink -nls 
+ntlm +opie -psl +ssl/openssl 

Wgetrc: 
    /Users/david/.wgetrc (user) 
    /usr/local/etc/wgetrc (system) 
Compile: 
    clang -DHAVE_CONFIG_H -DSYSTEM_WGETRC="/usr/local/etc/wgetrc" 
    -DLOCALEDIR="/usr/local/Cellar/wget/1.19.1/share/locale" -I. 
    -I../lib -I../lib -I/usr/local/opt/openssl/include -DNDEBUG 
Link: 
    clang -DNDEBUG -liconv -L/usr/local/opt/openssl/lib -lssl -lcrypto 
    -ldl -lz ftp-opie.o openssl.o http-ntlm.o ../lib/libgnu.a 


$ wget --content-disposition -c https://sourceforge.net/projects/freetype/files/freetype2/2.8/freetype-2.8.tar.bz2 
--2017-07-25 10:55:27-- https://sourceforge.net/projects/freetype/files/freetype2/2.8/freetype-2.8.tar.bz2 
Resolving sourceforge.net... 216.34.181.60 
Connecting to sourceforge.net|216.34.181.60|:443... connected. 
HTTP request sent, awaiting response... 
    HTTP/1.1 302 Found 
    Server: nginx 
    Date: Tue, 25 Jul 2017 08:55:28 GMT 
    Content-Type: text/html; charset=UTF-8 
    Content-Length: 365 
    Connection: close 
    Pragma: no-cache 
    Cache-Control: no-cache 
    X-UA-Compatible: IE=edge,chrome=1 
    X-Frame-Options: SAMEORIGIN 
    Content-Security-Policy: upgrade-insecure-requests 
    Set-Cookie: VISITOR=2b8474db-e3d7-4710-8a3d-974b86ef1b5a; expires="Fri, 23-Jul-2027 08:55:28 GMT"; httponly; Max-Age=315360000; Path=/ 
    Set-cookie: sourceforge=bcda7ec9e4ed439a64c5e64e590620b984ed89bcgAJ9cQEoVQVwcmVmc3ECfXEDVQ5fYWNjZXNzZWRfdGltZXEER0HWXcHgBmPgVQNrZXlxBVUkMmI4NDc0ZGItZTNkNy00NzEwLThhM2QtOTc0Yjg2ZWYxYjVhcQZVDl9jcmVhdGlvbl90aW1lcQdHQdZdweAGY9xVA19pZHEIVSA0MzRjODBmYjk0NjM0ZGNmYjU4Y2JhYWIxODdkMjVkN3EJdS4=; expires=Tue, 19-Jan-2038 03:14:07 GMT; httponly; Path=/; secure 
    Location: https://sourceforge.net/projects/freetype/files/freetype2/2.8/freetype-2.8.tar.bz2/download 
    X-Content-Type-Options: nosniff 
    Strict-Transport-Security: max-age=31536000 
Location: https://sourceforge.net/projects/freetype/files/freetype2/2.8/freetype-2.8.tar.bz2/download [following] 
--2017-07-25 10:55:28-- https://sourceforge.net/projects/freetype/files/freetype2/2.8/freetype-2.8.tar.bz2/download 
Connecting to sourceforge.net|216.34.181.60|:443... connected. 
HTTP request sent, awaiting response... 
    HTTP/1.1 200 OK 
    Server: nginx 
    Date: Tue, 25 Jul 2017 08:55:28 GMT 
    Content-Type: text/html; charset=utf-8 
    Content-Length: 128476 
    Connection: close 
    Pragma: no-cache 
    Cache-Control: no-cache 
    X-UA-Compatible: IE=edge,chrome=1 
    X-Frame-Options: SAMEORIGIN 
    Content-Security-Policy: upgrade-insecure-requests 
    Set-Cookie: VISITOR=2b8474db-e3d7-4710-8a3d-974b86ef1b5a; expires="Fri, 23-Jul-2027 08:55:28 GMT"; httponly; Max-Age=315360000; Path=/ 
    Set-cookie: sourceforge=797e45184f27a13d79e45d16b390a5e0bc9ef06dgAJ9cQEoVQhfZXhwaXJlc3ECY2RhdGV0aW1lCmRhdGV0aW1lCnEDVQoH9gETAw4HAAAAhVJxBFUDX2lkcQVVIDQzNGM4MGZiOTQ2MzRkY2ZiNThjYmFhYjE4N2QyNWQ3cQZVBmRsaGlzdHEHXXEIfXEJKFUHcmVsZWFzZXEKfXELKFUEZGF0ZXEMaANVCgfhBQ0KNwAAAACFUnENVQpzZl9maWxlX2lkcQ5KtGSWAVUIZmlsZW5hbWVxD1gjAAAAL2ZyZWV0eXBlMi8yLjgvZnJlZXR5cGUtMi44LnRhci5iejJxEHVVB3Byb2plY3RxEX1xEihVCXNob3J0bmFtZXETWAgAAABmcmVldHlwZXEUVQVzZl9pZHEVTVUMVQRuYW1lcRZYFAAAAFRoZSBGcmVlVHlwZSBQcm9qZWN0cRd1dWFVA2tleXEYVSQyYjg0NzRkYi1lM2Q3LTQ3MTAtOGEzZC05NzRiODZlZjFiNWFxGVUKY3VycmVudF9vc3EaXXEbKFUFd2luMzJxHFUHV2luZG93c3EdZVUFcHJlZnNxHn1xH1UOX2FjY2Vzc2VkX3RpbWVxIEdB1l3B4C2D8VUOX2NyZWF0aW9uX3RpbWVxIUdB1l3B4AZj3HUu; expires=Tue, 19-Jan-2038 03:14:07 GMT; httponly; Path=/; secure 
    X-Content-Type-Options: nosniff 
    Strict-Transport-Security: max-age=31536000 
Length: 128476 (125K) [text/html] 
Last-modified header missing -- time-stamps turned off. 
--2017-07-25 10:55:28-- https://sourceforge.net/projects/freetype/files/freetype2/2.8/freetype-2.8.tar.bz2/download 
Connecting to sourceforge.net|216.34.181.60|:443... connected. 
HTTP request sent, awaiting response... 
    HTTP/1.1 200 OK 
    Server: nginx 
    Date: Tue, 25 Jul 2017 08:55:29 GMT 
    Content-Type: text/html; charset=utf-8 
    Content-Length: 143733 
    Connection: close 
    Pragma: no-cache 
    Cache-Control: no-cache 
    X-UA-Compatible: IE=edge,chrome=1 
    X-Frame-Options: SAMEORIGIN 
    Content-Security-Policy: upgrade-insecure-requests 
    Set-Cookie: VISITOR=2b8474db-e3d7-4710-8a3d-974b86ef1b5a; expires="Fri, 23-Jul-2027 08:55:29 GMT"; httponly; Max-Age=315360000; Path=/ 
    Set-cookie: sourceforge=b5bd929d9431625f7b220b04e97d1949367d4ed4gAJ9cQEoVQhfZXhwaXJlc3ECY2RhdGV0aW1lCmRhdGV0aW1lCnEDVQoH9gETAw4HAAAAhVJxBFUDX2lkcQVVIDQzNGM4MGZiOTQ2MzRkY2ZiNThjYmFhYjE4N2QyNWQ3cQZVBmRsaGlzdHEHXXEIfXEJKFUHcmVsZWFzZX1xCihVBGRhdGVoA1UKB+EFDQo3AAAAAIVScQtVCnNmX2ZpbGVfaWRKtGSWAVUIZmlsZW5hbWVYIwAAAC9mcmVldHlwZTIvMi44L2ZyZWV0eXBlLTIuOC50YXIuYnoydVUHcHJvamVjdH1xDChVCXNob3J0bmFtZVgIAAAAZnJlZXR5cGVVBXNmX2lkTVUMVQRuYW1lWBQAAABUaGUgRnJlZVR5cGUgUHJvamVjdHV1YVUDa2V5cQ1VJDJiODQ3NGRiLWUzZDctNDcxMC04YTNkLTk3NGI4NmVmMWI1YXEOVQpjdXJyZW50X29zcQ9dcRAoVQV3aW4zMnERVQdXaW5kb3dzcRJlVQVwcmVmc3ETfXEUVQ5fYWNjZXNzZWRfdGltZXEVR0HWXcHgU/ahVQ5fY3JlYXRpb25fdGltZXEWR0HWXcHgBmPcdS4=; expires=Tue, 19-Jan-2038 03:14:07 GMT; httponly; Path=/; secure 
    X-Content-Type-Options: nosniff 
    Strict-Transport-Security: max-age=31536000 
Length: 143733 (140K) [text/html] 
Saving to: ‘download.html’ 

download.html          100%[============================================================================================================>] 140.36K 338KB/s in 0.4s 

2017-07-25 10:55:29 (338 KB/s) - ‘download.html’ saved [143733/143733] 

ответ

2

Вы можете использовать Wget, только если вы все хорошо, что вы будете использовать экспериментальную функциональность, которая искомая "--content-disposition" опция.

wget --content-disposition -c https://sourceforge.net/projects/freetype/files/freetype2/2.8/freetype-2.8.tar.bz2 

Все перенаправления обрабатываются автоматически, см. Выход ниже.

--2017-07-22 22:26:05-- https://sourceforge.net/projects/freetype/files/freetype2/2.8/freetype-2.8.tar.bz2 
Resolving sourceforge.net... 216.34.181.60 
Connecting to sourceforge.net|216.34.181.60|:443... connected. 
HTTP request sent, awaiting response... 302 Found 
Location: https://sourceforge.net/projects/freetype/files/freetype2/2.8/freetype-2.8.tar.bz2/download [following] 
--2017-07-22 22:26:06-- https://sourceforge.net/projects/freetype/files/freetype2/2.8/freetype-2.8.tar.bz2/download 
Connecting to sourceforge.net|216.34.181.60|:443... connected. 
HTTP request sent, awaiting response... 302 Found 
Location: https://downloads.sourceforge.net/project/freetype/freetype2/2.8/freetype-2.8.tar.bz2?r=&ts=1500755167&use_mirror=kent [following] 
--2017-07-22 22:26:07-- https://downloads.sourceforge.net/project/freetype/freetype2/2.8/freetype-2.8.tar.bz2?r=&ts=1500755167&use_mirror=kent 
Resolving downloads.sourceforge.net... 216.34.181.59 
Connecting to downloads.sourceforge.net|216.34.181.59|:443... connected. 
HTTP request sent, awaiting response... 302 Found 
Location: https://kent.dl.sourceforge.net/project/freetype/freetype2/2.8/freetype-2.8.tar.bz2 [following] 
--2017-07-22 22:26:08-- https://kent.dl.sourceforge.net/project/freetype/freetype2/2.8/freetype-2.8.tar.bz2 
Resolving kent.dl.sourceforge.net... 212.219.56.185 
Connecting to kent.dl.sourceforge.net|212.219.56.185|:443... connected. 
HTTP request sent, awaiting response... 200 OK 
Length: 1873526 (1.8M) [application/octet-stream] 
--2017-07-22 22:26:08-- https://kent.dl.sourceforge.net/project/freetype/freetype2/2.8/freetype-2.8.tar.bz2 
Connecting to kent.dl.sourceforge.net|212.219.56.185|:443... connected. 
HTTP request sent, awaiting response... 200 OK 
Length: 1873526 (1.8M) [application/octet-stream] 
Saving to: ‘freetype-2.8.tar.bz2’ 

freetype-2.8.tar.bz2        100%[==========================================================================================================>] 1.79M 5.60MB/s in 0.3s 

2017-07-22 22:26:08 (5.60 MB/s) - ‘freetype-2.8.tar.bz2’ saved [1873526/1873526] 

Update предоставить более подробную информацию

➜ ~ ls -ld $(which wget) 
lrwxr-xr-x 1 duda admin 32 4 črv 19:44 /usr/local/bin/wget -> ../Cellar/wget/1.19.1_1/bin/wget 
➜ ~ wget --version 
GNU Wget 1.19.1 built on darwin16.6.0. 

-cares +digest -gpgme +https +ipv6 -iri +large-file -metalink -nls 
+ntlm +opie -psl +ssl/openssl 

Wgetrc: 
    /usr/local/etc/wgetrc (system) 
Compile: 
    clang -DHAVE_CONFIG_H -DSYSTEM_WGETRC="/usr/local/etc/wgetrc" 
    -DLOCALEDIR="/usr/local/Cellar/wget/1.19.1_1/share/locale" -I. 
    -I../lib -I../lib -I/usr/local/opt/[email protected]/include -DNDEBUG 
Link: 
    clang -DNDEBUG -liconv -L/usr/local/opt/[email protected]/lib -lssl 
    -lcrypto -ldl -lz ftp-opie.o openssl.o http-ntlm.o ../lib/libgnu.a 

Copyright (C) 2015 Free Software Foundation, Inc. 
License GPLv3+: GNU GPL version 3 or later 
<http://www.gnu.org/licenses/gpl.html>. 
This is free software: you are free to change and redistribute it. 
There is NO WARRANTY, to the extent permitted by law. 

Originally written by Hrvoje Niksic <[email protected]>. 
Please send bug reports and questions to <[email protected]>. 
+0

Выполнение этой команды в OSX, я получаю файл «download.html» (который является HTML-файл), вместо bz2 файла. моя команда wget не жалуется на параметр '--content-disposition', поэтому я предполагаю, что он ее принимает. любая идея, почему он не работает на моем компьютере? –

+0

Работает на моем MacOS. Я использую wget из доморощенного. '➜ ~ wget --help' ' GNU Wget 1.19.1, неинтерактивный сетевой ретривер. – vookimedlo

+0

Я также использую wget 1.19.1 из homebrew. это так странно ... я отправил свой журнал в мой вопрос. –

Смежные вопросы