我正在尝试使用exec()
我youtube-dl
在CentOS服务器上安装的PHP以JSON格式获取视频详细信息。通过/
运行就可以了。我的脚本返回空页:(youtube-dl -J <VideoURL>
SSH
Terminal
test.php
echo exec("youtube-dl -J <VideoURL>");
//Installed via pip
//OR
echo exec("python /home/site/youtube-dl -J <VideoURL>");
//Downloaded as file named youtube-dl
exec
如果我像这样测试,则启用:
if(function_exists('exec')) {
echo "exec is enabled";
}
IP
YouTube无法阻止服务器的运行,因为我可以通过终端成功运行命令
通过在test.php
文件中执行以下操作,我能够实现您的目标
<?php
if(function_exists('shell_exec')) {
header('Content-Type: application/json');
echo shell_exec("youtube-dl -J https://www.youtube.com/watch?v=zGDzdps75ns");
}
?>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句