【问题标题】:Curl Error,displaying webpage ,not result卷曲错误,显示网页,没有结果
【发布时间】:2014-03-23 08:05:44
【问题描述】:

我对 php 有点陌生。我找到了一种使用 curl 并在另一个页面中显示网页的方法。它工作正常。但是原始页面上有一个搜索功能。当我搜索页面时它不会给出任何结果。

正在谈论的网站是 http://bit.ly/1jhLxMm 注意:原站点隐私的 URL 缩短

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://the-site-i-meationed-above.com");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$result = curl_exec($ch);
curl_close($ch);
$result = preg_replace("/Powered By/",'', $result);
echo $result
?>

我尝试使用 iframe,一切正常。但我不想使用 iframe 并完全在 curl 中完成。我希望有人可以帮助我。谢谢

【问题讨论】:

  • Howard 给出了一个使用另一个站点的 html 表单并添加 $result = preg_replace("/Powered By/",'', $result); 的有效示例。我说明了我的理由给操作提供一种方法来扭转它(通过解释他们的用例并确认有这样做的权限)。

标签: javascript php iframe curl


【解决方案1】:

您的代码有语法错误。您希望它如何运行?将分号放在要打印结果的位置:

echo $result;
            ^--- can you see this??

如果您直接使用bit.ly/ 链接,也添加这个来处理重定向:

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);

【讨论】:

  • 测试仍然没有结果:(新源:the-site-i-meationed-above.com"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); $result = curl_exec($ch); curl_close($ch); $result = preg_replace("/Powered By/",'', $result); 回显 $result; ?>
  • @ArunGreen add curl_setopt($ch, CURLOPT_VERBOSE, TRUE); 并向我们展示它的输出?
  • @ArunGreen verbose 不用于输出。它将在日志或屏幕上打印 curl 的调试消息。如果你想要你的答案,你必须提供。否则我无能为力。
  • * About to connect() to fast2sms.com port 80 (#0) * Trying 192.3.149.121... * connected * Connected to fast2sms.com (192.3.149.121) port 80 (#0) &gt; GET /tracker.php HTTP/1.1 Host: fast2sms.com Accept: */* &lt; HTTP/1.1 200 OK &lt; Date: Sun, 23 Mar 2014 09:08:20 GMT &lt; Server: Apache/2.2.26 (Unix) mod_ssl/2.2.26 OpenSSL/1.0.1e-fips mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
  • &lt; X-Powered-By: PHP/5.4.23 &lt; Expires: Thu, 19 Nov 1981 08:52:00 GMT &lt; Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 &lt; Pragma: no-cache &lt; Set-Cookie: PHPSESSID=0bbcb792ce3392a5f6a34967796e9547; path=/ &lt; Transfer-Encoding: chunked &lt; Content-Type: text/html &lt; * Connection #0 to host fast2sms.com left intact * Closing connection #0
猜你喜欢
  • 2017-11-25
  • 2021-05-27
  • 1970-01-01
  • 2018-06-07
  • 1970-01-01
  • 2020-04-10
  • 2016-11-30
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多