不pipe我为curl指定的URL是什么,我总是得到相同的HTML 404错误页面。
如果我使用--verbose选项,它看起来像curl总是连接到相同的IP地址。
$ curl --verbose http://www.edgeoftheweb.co.uk * About to connect() to www.edgeoftheweb.co.uk port 80 * Trying ::ffff:74.117.222.24... connected * Connected to www.edgeoftheweb.co.uk (::ffff:74.117.222.24) port 80 > GET / HTTP/1.1 > User-Agent: curl/7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 > Host: www.edgeoftheweb.co.uk > Accept: */* > < HTTP/1.1 200 OK < Date: Thu, 15 Sep 2011 13:52:07 GMT < Server: Apache/2.2.3 (CentOS) < X-Powered-By: PHP/5.2.11 < Content-Length: 519 < Connection: close < Content-Type: text/html; charset=UTF-8 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <TITLE>www.edgeoftheweb.co.uk</TITLE> </HEAD> <FRAMESET rows="100%,*" border="0" frameborder="0" framespacing="0"> <FRAME name=top src="http://www.searchnut.com/?domain=edgeoftheweb.co.uk®istrar=directnicexpired&aff_txt=This+domain+is+expired%2C+please+renew+it.&aff_url=https%3A%2F%2Fsecure.directnic.com%2Fmyaccount%2Frenewals%2F" noresize> </FRAMESET> Closing connection #0 $ curl --verbose http://api.twitter.com * About to connect() to api.twitter.com port 80 * Trying ::ffff:74.117.222.24... connected * Connected to api.twitter.com (::ffff:74.117.222.24) port 80 > GET / HTTP/1.1 > User-Agent: curl/7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 > Host: api.twitter.com > Accept: */* > < HTTP/1.1 200 OK < Date: Thu, 15 Sep 2011 13:53:25 GMT < Server: Apache/2.2.3 (CentOS) < X-Powered-By: PHP/5.2.11 < Content-Length: 505 < Connection: close < Content-Type: text/html; charset=UTF-8 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <TITLE>api.twitter.com</TITLE> </HEAD> <FRAMESET rows="100%,*" border="0" frameborder="0" framespacing="0"> <FRAME name=top src="http://www.searchnut.com/?domain=twitter.com®istrar=directnicexpired&aff_txt=This+domain+is+expired%2C+please+renew+it.&aff_url=https%3A%2F%2Fsecure.directnic.com%2Fmyaccount%2Frenewals%2F" noresize> </FRAMESET> Closing connection #0
curl --version的输出是:
curl 7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 Protocols: tftp ftp telnet dict ldap http file https ftps Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz
如果我使用wget ,那么我会找回正确的页面。
任何想法如何得到curl解决URL的正确? 谢谢。
* Connected to www.edgeoftheweb.co.uk (::ffff:74.117.222.24) port 80 * Connected to api.twitter.com (::ffff:74.117.222.24) port 80
在我看来,curl使用ipv6连接,而wget使用ipv4
尝试以下
curl --verbose -4 http://api.twitter.com
这是一个很长的一段时间,但尝试将您的名称服务器暂时更改为Google的DNS服务器:
8.8.8.8 8.8.4.4
看起来像是libcurl不能parsing这些DNS名称,但是你的ISP的DNS服务器没有返回一个正确的DNS响应(NXDOMAIN),而是返回一个search结果。 我不知道为什么wget在响应方面会有很大的不同,但是至less你可能会希望你的ISP服务器阻碍你的故障排除。