【问题标题】:Curl with exclamation mark + hasthag in target URL目标 URL 中带有感叹号 + hasthag 的卷曲
【发布时间】:2013-06-17 01:52:09
【问题描述】:

我正在尝试在目标 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

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

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

【问题讨论】:

标签: php curl ssh nginx


【解决方案1】:

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

【讨论】:

  • 我不介意,但我尝试了双引号并遇到了同样的问题。甚至没有想到单引号。卷曲的结果不符合预期,和直接访问url的输出不一样。
  • 因为是 javascript 在 shebang 之后处理所有事情,所以你需要类似 phantomjs.org 的东西来打开带有 js 支持的 url。
  • 我刚刚读了一篇类似的帖子,答案是 phantonjs.org 我会去看看。
  • 好吧,刚刚安装了phantomjs,现在遇到了这个问题。在 SSH 上工作正常,但在 PHP 上不行。我应该打开一个新问题来解决和引用这个问题吗?
  • 你的意思是php不能用?你是如何使用 php 的?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-21
  • 2013-08-13
  • 1970-01-01
  • 2021-04-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多