php - 在目标 URL 中使用感叹号 + 主题标签进行 curl

标签 php curl ssh nginx

我正在尝试在目标 url 中使用主题标签进行简单的 curl - 但出现错误。

我知道这个脚本有效,我以前用过很多次。

<?php

error_reporting(E_ALL);

$curl = curl_init('http://tools.pingdom.com/fpt/#!/d3YvU8/http://www.nginx-hosting.co.uk');
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);  
$result = curl_exec($curl);

if ($result == ("")) {
echo ("Nothing to curl");
}
else {
echo $result;
}

?> 

下面是上面的脚本:http://www.nginx-hosting.co.uk/curl_test.php

如您所见,输出与预期的完全不同。我通过 SSH 运行相同的命令:

curl http://tools.pingdom.com/fpt/#!/d3YvU8/http://www.nginx-hosting.co.uk

但是得到这个错误信息-bash: !/d3YvU8/http: event not found

我认为这是因为目标网址中有感叹号或主题标签。

请有人指出我正确的方向。提前致谢

最佳答案

我刚试过你的脚本,它工作得很好,关于 -bash: !/d3YvU8/http: event not found 错误,你应该使用像这样的引号:curl ' http://tools.pingdom.com/fpt/#!/d3YvU8/http://www.nginx-hosting.co.uk '

关于php - 在目标 URL 中使用感叹号 + 主题标签进行 curl ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17209710/

相关文章:

python - 使用curl获取csv的shell脚本

bash - WGET 不适用于 plunder.com

php - 如何检查 INSERT IGNORE 是否实际插入了来自 php 的行

php - 在 myphp 中添加项目

python - JSON解码错误: Expecting value: line 1 column 1 (char 0)

来自文件路径的 PHP CURL PUT

linux - 如何从 expect 脚本中传递的 shell 'read' 命令返回?

SSH 的 java.sql.Connection 扩展

php - javascript 中是否有类似于 php 中的 compact 的函数?

php - 发送动态表到mysql