我试着在目标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
我认为这是因为目标url中有一个感叹号或hashtag。
有人能告诉我怎么走吗?提前感谢
发布于 2013-06-20 17:14:33
我刚刚试过你的脚本,它工作得很好,关于-bash: !/d3YvU8/http: event not found
错误,你应该用引号: curl‘http://tools.pingdom.com/fpt/#!/d3YvU8/http://www.nginx-hosting.co.uk’
https://stackoverflow.com/questions/17209710
复制相似问题