使用curl从php服务器下载文件 [英] Download a file using curl from a php server

查看:198
本文介绍了使用curl从php服务器下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写一个脚本,将从lazyfoo.net的教程中下载所有的源材料。该文件的示例下载链接为

I'm trying to write a script that will download all the source material from the tutorials at lazyfoo.net. An example download link for the file is

http://lazyfoo.net/downloads/index.php?file=SDLTut_lesson16

我使用此命令:

curl http://lazyfoo.net/downloads/index.php?file=SDLTut_lesson13 --O lesson13.zip

这给我这个响应,没有文件:

This gets me this response and no file:

 % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                Dload  Upload   Total   Spent    Left  Speed
 0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

我缺少明显的东西?

推荐答案

您得到了302重定向。使用 -L 选项

You are getting a 302 redirect. Use the -L option

curl http://lazyfoo.net/downloads/index.php?file=SDLTut_lesson13 -L --O lesson13.zip

-v (代表verbose)可用于调试。

Also in future -v (stands for verbose) is useful for debugging.

这篇关于使用curl从php服务器下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆