使用cURL实用程序进行网页下载 - 代理循环问题

时间:2013-11-26 14:44:12

标签: windows unix networking curl proxy

我正在尝试使用cURL for Windows 32位(使用SSH版本)从我的工作中访问google.com。我通过我公司的代理服务器进行连接但是我收到了400个代理周期检测错误。有人可以让我知道为什么我会收到此错误。命令&错误消息如下(代理IP更改为XXXX):

命令:

%curl -A "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0b7pre) Gecko/20100925 Firefox/4.0b7pre"  -v --proxy-ntlm XXX.XXX.XXX.XXX:8080 -U name:password -I http://www.google.com

输出:

Enter proxy password for user 'name':
* Rebuilt URL to:  XXX.XXX.XXX.XXX:8080/
* About to connect() to XXX.XXX.XXX.XXX port 8080 (#0)
*   Trying XXX.XXX.XXX.XXX...
* Adding handle: conn: 0xcb0520
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0xcb0520) send_pipe: 1, recv_pipe: 0
* Connected to XXX.XXX.XXX.XXX (XXX.XXX.XXX.XXX) port 8080 (#0)
> HEAD / HTTP/1.1
> User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0b7pre) Gecko/20100925 Firefox/4.0b7pre
> Host: XXX.XXX.XXX.XXX:8080
> Accept: */*
>
< HTTP/1.1 400 Cycle Detected
HTTP/1.1 400 Cycle Detected
< Date: Mon, 25 Nov 2013 11:56:06 GMT
Date: Mon, 25 Nov 2013 11:56:06 GMT
< Via: 1.1 localhost.localdomain
Via: 1.1 localhost.localdomain
< Cache-Control: no-store
Cache-Control: no-store
< Content-Type: text/html
Content-Type: text/html
< Content-Language: en
Content-Language: en
< Content-Length: 288
Content-Length: 288

<
* Connection #0 to host XXX.XXX.XXX.XXX left intact
* Rebuilt URL to: http://www.google.com/
* Adding handle: conn: 0xcb12f8
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 1 (0xcb12f8) send_pipe: 1, recv_pipe: 0
* About to connect() to www.google.com port 80 (#1)
*   Trying 173.194.115.50...
* Connection refused
*   Trying 173.194.115.51...
* Connection refused
*   Trying 173.194.115.49...
* Connection refused
*   Trying 173.194.115.48...
* Connection refused
*   Trying 173.194.115.52...
* Connection refused
* Failed connect to www.google.com:80; Connection refused
* Closing connection 1
curl: (7) Failed connect to www.google.com:80; Connection refused

对于它的价值,我可以使用所述代理地址通过浏览器连接到google.com。我确信我正确地提供了密码(代理)。

2 个答案:

答案 0 :(得分:2)

您已通过--proxy参数设置代理,或者通过--proxy-ntlm设置-x参数,请尝试此操作

curl -A "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0b7pre) Gecko/20100925 Firefox/4.0b7pre" -L --proxy http://xxx.xxx.xxx.xxx:8080 --proxy-ntlm -U name:password http://www.google.com 

如果您输入新的重定向周期,可以尝试不使用-L参数或设置--max-redirs参数。

cURL manpage

答案 1 :(得分:0)

我相信你因身份验证而被淘汰。您的工作代理可能需要进行身份验证才能通过它访问网站。

如果您的作品使用Active Directory SSO(单点登录),请尝试使用您的域用户名和密码:

curl --ntlm --user username:password http://www.google.com

或者不,尝试以下基本身份验证:

curl --user username:password http://www.google.com