如何使用wget从SourceForge下载文件?

时间:2016-11-01 10:23:53

标签: wget sourceforge

我正在编写一个需要从sourceforge下载发布文件的脚本。如何获得良好的链接?

同样的问题及其答案在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’

更新:记录@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 个答案:

答案 0 :(得分:4)

只有在您使用实验功能时才能使用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]

更新 以提供更多详情

➜  ~ 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/openssl@1.1/include -DNDEBUG
Link:
    clang -DNDEBUG -liconv -L/usr/local/opt/openssl@1.1/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 <hniksic@xemacs.org>.
Please send bug reports and questions to <bug-wget@gnu.org>.

答案 1 :(得分:0)

尝试一下:

wget -O [filename] [link to the downloadable file]

示例:

wget -O TransLiG_1.3.tar.gz https://sourceforge.net/projects/transcriptomeassembly/files/TransLiG/TransLiG_1.3.tar.gz/download