cURL GET请求不返回任何输出

cURL GET请求不返回任何输出,curl,Curl,我正在发送一个简单的curl请求到pinterest.com。当我使用PHP时,不会显示任何结果。我在命令行中尝试了它,但没有结果。然后我在curl中尝试了详细模式,它给出了: curl 7.27.0 (i686-pc-linux-gnu) libcurl/7.27.0 OpenSSL/1.0.1c zlib/1.2.7 libidn/1.25 librtmp/2.3 Protocols: dict file ftp ftps gopher http https imap imaps ldap

我正在发送一个简单的
curl
请求到
pinterest.com
。当我使用
PHP
时,不会显示任何结果。我在命令行中尝试了它,但没有结果。然后我在
curl
中尝试了详细模式,它给出了:

curl 7.27.0 (i686-pc-linux-gnu) libcurl/7.27.0 OpenSSL/1.0.1c zlib/1.2.7 libidn/1.25 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smtp smtps telnet tftp 
Features: Debug GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP
我已经找过了,但找不出答案。我做错了什么

命令是:

curl -v pinterest.com

检查标题:只能通过https访问:

$ curl --dump-header - http://pinterest.com/
HTTP/1.1 302 FOUND
Accept-Ranges: bytes
Age: 0
Content-Type: text/html; charset=utf-8
Date: Thu, 18 Jul 2013 19:25:49 GMT
Etag: "d41d8cd98f00b204e9800998ecf8427e"
Location: https://pinterest.com/
Pinterest-Breed: CORGI
Pinterest-Generated-By: ngapp-b7f64694
Pinterest-Version: a8eef3c
Server: nginx/0.8.54
Set-Cookie: csrftoken=A2VQZGarr509JKxrJxiuW2MbrXNdHlUH; Domain=.pinterest.com; expires=Thu, 17-Jul-2014 19:25:49 GMT; Max-Age=31449600; Path=/
Set-Cookie: _pinterest_sess="eJwz84isyvfJcilP1S4szHY20A6MKitJKwwPdi+2tY8vycxNtfUN8TX2c3E19gsJNfAPtLVVK04tLs5MsfXMcjTxq/KsAGJj3/CgHL+QoGzfrLCMSKNAIz93X+PIrHQTIF0eFe6X4ZluawsAh3UjNA=="; Domain=.pinterest.com; expires=Sun, 13-Jul-2014 19:25:49 GMT; Max-Age=31103999; Path=/
Vary: Cookie
Via: 1.1 varnish
X-Varnish: 1991078486
Content-Length: 0
Connection: keep-alive
如果使用
-L
选项,您将获得以下页面:

$ curl -L http://pinterest.com/
<!DOCTYPE html>
<!--[if IE 7 ]><html lang="en" class="ie7 ielt9 ielt10 en"><![endif]-->
<!--[if IE 8 ]><html lang="en" class="ie8 ielt9 ielt10 en"><![endif]-->
<!--[if IE 9 ]><html lang="en" class="ie9 ielt10 en"><![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--><html lang="en" class=" en"><!--<![endif]-->

<head>
    <script>
[snip]
$curl-Lhttp://pinterest.com/
[剪报]
以下是如何使用PHP实现的:


[几年后…]而且,
-V
--version
,而不是
--verbose
,它是小写的
-V
。调用
curl-V
会导致它显示版本并忽略任何参数,因此无论如何您都不会以这种方式获取页面。

目标站点URL执行重定向可能有问题

默认情况下,当curl在发出请求后收到重定向时,它不会向新URL发出请求。作为一个例子,考虑URL。当您使用此URL发出请求时,服务器将向发送HTTP 3XX重定向。如果尝试以下操作,将得到空输出:

$curl $ 如果希望cURL遵循这些重定向,则应使用-L选项

$curl-L

您可以以pinterest.com为例进行尝试。
比较“curl-pinterest.com”和“curl-L pinterest.com”的输出

它给出了:~$curl-D curl:没有指定URL!curl:请尝试“curl--help”或“curl--manual”了解更多信息,有什么建议吗\把我的剪贴画弄脏了。将立即修复。-D需要一个arg,对于stdout可以是“-”。我注意到我的剪切和粘贴有很多问题,但没有发现。很抱歉。