简体   繁体   English

使用wget和php来下载通过脚本远程生成的图像

[英]using wget with php to download images generated via script remotely

Good day all. 大家好。

I have this problem, I need to download a lot of images, I have the ppossibility to use wget to achieve this, but I got some problems. 我有这个问题,我需要下载很多图像,我有可能使用wget来实现这一目标,但是我遇到了一些问题。

first, I have try wget itself: 首先,我尝试尝试wget本身:

system('wget -q http://www.google.com/images/logo_sm.gif -O test2.gif');

ok, it works, I can do it ... So, I changed the parameters, putting the real URL and a subdirectory where to save: 好的,它可以正常工作,我可以做到的...所以,我更改了参数,将真实的URL和一个子目录保存到其中:

system('wget -q -nH '.$row['foto'].' -O ./img/'.$row['modello'].'.jpg');

that is been parsed in: 被解析为:

wget -q -nH http://server.com/main.php?action=exec&task=show_image&task_arg=23456&m=not&ft=product_full_image_1&auth=d84a122342332ff2d1dssssff06d0199 -O ./img/0561142.jpg

this time I get a werid result, something like a thousands 11 bytes files called main.php?action=exec### have been created in the same directory of the script (note that ### is a 3 digit number ). 这次我得到了一个很好的结果,在脚本的同一目录中创建了一个名为main.php?action = exec ###的数千个11字节文件(请注意,###是3位数字)。

I understand that there is something wrong...maybe url parameters? 我知道有什么问题...也许是网址参数? maybe the subdirectory? 也许子目录? what I'm messing? 我在搞什么 is system the god choiche? system是上帝的选择吗? or maybe exec is better? 还是exec更好? or whatever? 管他呢?

thanks in advance. 提前致谢。

Ampersand, and other characters, has special meaning in shell syntax. &符和其他字符在shell语法中具有特殊含义。 If you really can't use PHP's built-in cURL library you should at least escape the shell options before adding them to the command. 如果您确实无法使用PHP的内置cURL库 ,则在将它们添加到命令之前,至少应转义shell选项

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM