wget sourceforge 最新7zip批处理
Wget sourceforge latest 7zip batch
我想使用 wget 获取最新版本的 64 位和 32 位 7zip。但是,如果我使用 wget,它不会从文件夹中下载 exe 文件,而只会下载名为“7z1507-extra.7z”的文件。我怎样才能只得到 .EXE 文件?
我调用的命令:
wget "http://sourceforge.net/projects/sevenzip/files/latest/download" - log.txt --trust-server-name
日志文件:
--2015-09-25 21:48:51--
http://sourceforge.net/projects/sevenzip/files/latest/download
Resolving sourceforge.net (sourceforge.net)... 216.34.181.60
Connecting to sourceforge.net (sourceforge.net)|216.34.181.60|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://downloads.sourceforge.net/project/sevenzip/7-Zip/15.07/7z1507-extra.7z?r=&ts=1443210538&use_mirror=skylink [following]
--2015-09-25 21:48:51-- http://downloads.sourceforge.net/project/sevenzip/7-Zip/15.07/7z1507-extra.7z?r=&ts=1443210538&use_mirror=skylink
Resolving downloads.sourceforge.net (downloads.sourceforge.net)... 216.34.181.59
Connecting to downloads.sourceforge.net (downloads.sourceforge.net)|216.34.181.59|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://skylink.dl.sourceforge.net/project/sevenzip/7-Zip/15.07/7z1507-extra.7z [following]
--2015-09-25 21:48:52-- http://skylink.dl.sourceforge.net/project/sevenzip/7-Zip/15.07/7z1507-extra.7z
Resolving skylink.dl.sourceforge.net (skylink.dl.sourceforge.net)... 109.230.212.53
Connecting to skylink.dl.sourceforge.net (skylink.dl.sourceforge.net)|109.230.212.53|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 849832 (830K) [application/x-7z-compressed]
Saving to: '7z1507-extra.7z'
0K .......... .......... .......... .......... .......... 6% 848K 1s
50K .......... .......... .......... .......... .......... 12% 1.31M 1s
100K .......... .......... .......... .......... .......... 18% 2.10M 1s
150K .......... .......... .......... .......... .......... 24% 1.53M 0s
200K .......... .......... .......... .......... .......... 30% 4.76M 0s
250K .......... .......... .......... .......... .......... 36% 2.10M 0s
300K .......... .......... .......... .......... .......... 42% 5.13M 0s
350K .......... .......... .......... .......... .......... 48% 4.73M 0s
400K .......... .......... .......... .......... .......... 54% 4.02M 0s
450K .......... .......... .......... .......... .......... 60% 3.77M 0s
500K .......... .......... .......... .......... .......... 66% 3.73M 0s
550K .......... .......... .......... .......... .......... 72% 3.69M 0s
600K .......... .......... .......... .......... .......... 78% 3.76M 0s
650K .......... .......... .......... .......... .......... 84% 3.27M 0s
700K .......... .......... .......... .......... .......... 90% 4.05M 0s
750K .......... .......... .......... .......... .......... 96% 3.85M 0s
800K .......... .......... ......... 100% 3.88M=0.3s
2015-09-25 21:48:52 (2.56 MB/s) - '7z1507-extra.7z' saved [849832/849832]
查看我实际想要获取哪些文件:http://sourceforge.net/projects/sevenzip/files/7-Zip/15.07/
信息:我指定最新版本而不是例如 15.07,因为我总是想要最新版本。
需要更多信息,尽管问!
SourceForge returns 错误的 HTTP 重定向 url 当不是从浏览器访问时,这是他们的错,您可以在他们的支持论坛或其他地方提交错误报告。
但是仍然可以下载页面源代码,抓取正确的 url 并下载它:
@echo off
echo Retrieving correct download url...
for /f "delims=;? tokens=2" %%a in (
'wget http://sourceforge.net/projects/sevenzip/files/latest/download ^
-q -O - --user-agent="Mozilla/5.0 (Windows NT 6.0)" ^
^| find "meta http-equiv=""refresh"""'
) do (
for /f "delims== tokens=1*" %%b in ("%%a") do (
wget "%%c"
)
)
pause
解释:
--user-agent="Mozilla/5.0 (Windows NT 6.0)"
是 sourceforge 站点识别的最小用户代理字符串,这使它为我们提供了一个 html 页面,正如我们在浏览器中看到的那样。
-q
停止进度报告,-O -
将下载的页面打印到标准输出管道
find
从该管道读取并输出具有正确重定向的行 url:
<meta http-equiv="refresh" content="5; url=http://downloads.sourceforge.net/project/sevenzip/7-Zip/15.07/7z1507.exe?r=&ts=1443257723&use_mirror=netcologne">
for /f "delims=;? tokens=2"
解析上面的行,在 ;
和 ?
处拆分并提取第二个标记:url=http://downloads.sourceforge.net/project/sevenzip/7-Zip/15.07/7z1507.exe
for /f "delims== tokens=1*"
,同样地,在 =
处拆分并用 *
抓住它之后的所有内容
- 最后使用正确的url下载文件
我想使用 wget 获取最新版本的 64 位和 32 位 7zip。但是,如果我使用 wget,它不会从文件夹中下载 exe 文件,而只会下载名为“7z1507-extra.7z”的文件。我怎样才能只得到 .EXE 文件?
我调用的命令:
wget "http://sourceforge.net/projects/sevenzip/files/latest/download" - log.txt --trust-server-name
日志文件:
--2015-09-25 21:48:51--
http://sourceforge.net/projects/sevenzip/files/latest/download
Resolving sourceforge.net (sourceforge.net)... 216.34.181.60
Connecting to sourceforge.net (sourceforge.net)|216.34.181.60|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://downloads.sourceforge.net/project/sevenzip/7-Zip/15.07/7z1507-extra.7z?r=&ts=1443210538&use_mirror=skylink [following]
--2015-09-25 21:48:51-- http://downloads.sourceforge.net/project/sevenzip/7-Zip/15.07/7z1507-extra.7z?r=&ts=1443210538&use_mirror=skylink
Resolving downloads.sourceforge.net (downloads.sourceforge.net)... 216.34.181.59
Connecting to downloads.sourceforge.net (downloads.sourceforge.net)|216.34.181.59|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://skylink.dl.sourceforge.net/project/sevenzip/7-Zip/15.07/7z1507-extra.7z [following]
--2015-09-25 21:48:52-- http://skylink.dl.sourceforge.net/project/sevenzip/7-Zip/15.07/7z1507-extra.7z
Resolving skylink.dl.sourceforge.net (skylink.dl.sourceforge.net)... 109.230.212.53
Connecting to skylink.dl.sourceforge.net (skylink.dl.sourceforge.net)|109.230.212.53|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 849832 (830K) [application/x-7z-compressed]
Saving to: '7z1507-extra.7z'
0K .......... .......... .......... .......... .......... 6% 848K 1s
50K .......... .......... .......... .......... .......... 12% 1.31M 1s
100K .......... .......... .......... .......... .......... 18% 2.10M 1s
150K .......... .......... .......... .......... .......... 24% 1.53M 0s
200K .......... .......... .......... .......... .......... 30% 4.76M 0s
250K .......... .......... .......... .......... .......... 36% 2.10M 0s
300K .......... .......... .......... .......... .......... 42% 5.13M 0s
350K .......... .......... .......... .......... .......... 48% 4.73M 0s
400K .......... .......... .......... .......... .......... 54% 4.02M 0s
450K .......... .......... .......... .......... .......... 60% 3.77M 0s
500K .......... .......... .......... .......... .......... 66% 3.73M 0s
550K .......... .......... .......... .......... .......... 72% 3.69M 0s
600K .......... .......... .......... .......... .......... 78% 3.76M 0s
650K .......... .......... .......... .......... .......... 84% 3.27M 0s
700K .......... .......... .......... .......... .......... 90% 4.05M 0s
750K .......... .......... .......... .......... .......... 96% 3.85M 0s
800K .......... .......... ......... 100% 3.88M=0.3s
2015-09-25 21:48:52 (2.56 MB/s) - '7z1507-extra.7z' saved [849832/849832]
查看我实际想要获取哪些文件:http://sourceforge.net/projects/sevenzip/files/7-Zip/15.07/
信息:我指定最新版本而不是例如 15.07,因为我总是想要最新版本。
需要更多信息,尽管问!
SourceForge returns 错误的 HTTP 重定向 url 当不是从浏览器访问时,这是他们的错,您可以在他们的支持论坛或其他地方提交错误报告。
但是仍然可以下载页面源代码,抓取正确的 url 并下载它:
@echo off
echo Retrieving correct download url...
for /f "delims=;? tokens=2" %%a in (
'wget http://sourceforge.net/projects/sevenzip/files/latest/download ^
-q -O - --user-agent="Mozilla/5.0 (Windows NT 6.0)" ^
^| find "meta http-equiv=""refresh"""'
) do (
for /f "delims== tokens=1*" %%b in ("%%a") do (
wget "%%c"
)
)
pause
解释:
--user-agent="Mozilla/5.0 (Windows NT 6.0)"
是 sourceforge 站点识别的最小用户代理字符串,这使它为我们提供了一个 html 页面,正如我们在浏览器中看到的那样。-q
停止进度报告,-O -
将下载的页面打印到标准输出管道find
从该管道读取并输出具有正确重定向的行 url:
<meta http-equiv="refresh" content="5; url=http://downloads.sourceforge.net/project/sevenzip/7-Zip/15.07/7z1507.exe?r=&ts=1443257723&use_mirror=netcologne">
for /f "delims=;? tokens=2"
解析上面的行,在;
和?
处拆分并提取第二个标记:url=http://downloads.sourceforge.net/project/sevenzip/7-Zip/15.07/7z1507.exe
for /f "delims== tokens=1*"
,同样地,在=
处拆分并用*
抓住它之后的所有内容
- 最后使用正确的url下载文件