wget 执行php 文件夹,php – 从exec()或shell_exec()调用时wget不工作

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-2 20:39   2480   0

我正在尝试将我编写的wget命令集成到php脚本中.该命令以递归方式下载网站上的每个html / php文件(这是我在file_get_contents()中找不到的必需功能).我在终端窗口中测试了wget命令,但是当使用exec()或shell_exec()执行它时没有任何反应.我没有收到任何错误或警告.

这是有问题的命令,

wget --recursive -m --domains oooff.com --page-requisites --html-extension --convert-links -R gif,jpg,pdf http://www.oooff.com/

我尝试过exec()和shell_exec()的简单wget命令(没有那么多参数),但它们也不起作用.

如果wget不是一个选项,我愿意使用其他方法下载一个完整的网站.

我现在的代码是,

exec("wget google.com", $array);

然后在打印数组时它是空的

解决方法:

使用适当的选项调用wget

-q to remove it s information output

-O - to output the request response on stdout

php -r 'exec("wget -q -O - google.com", $array);var_dump($array);'

标签:php,wget,exec,shell-exec

来源: https://codeday.me/bug/20190702/1354465.html

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP