我有这个代理地址:125.119.175.48:8909

如何使用cURL(如cURL http://www.example.com)执行HTTP请求,但指定我的网络的代理地址?


当前回答

curl -I "https://www.google.com" -x 1.1.1.1:8080

其他回答

来自man curl:

-x, --proxy <[protocol://][user:password@]proxyhost[:port]>

     Use the specified HTTP proxy. 
     If the port number is not specified, it is assumed at port 1080.

使用以下方法

curl -I -x 192.168.XX: XX http://google.com

192.168.X。X:XX输入您的代理服务器ip和端口。

-v verbose模式,它将提供更多的详细信息,包括头和响应。

sudo curl -x http://10.1.1.50:8080/ -fsSL https://download.docker.com/linux/ubuntu/gpg

这对我来说很完美,错误来了,因为旋度需要设置 代理 记得把代理替换成你的代理,我的代理,“例子”是 http://10.1.1.50:8080。

如果代理正在使用自动代理与PAC文件。我们可以从javascript和PAC URL中找到实际的代理。

如果代理需要认证,我们可以先使用普通的web浏览器访问网站,会弹出认证对话框。认证完成后,我们可以使用wireshark捕获发送到代理服务器的http包,从http包中,我们可以从http头:proxy - authorization中获取认证令牌

然后我们可以设置http_proxy环境变量,并在http报头中包括认证令牌:Proxy-Authorization

出口http_proxy = http://proxyserver:端口

curl -H "Proxy-Authorization: xxxx" http://targetURL

总结一下所有提到的答案:

curl -x http://<user>:<pass>@<proxyhost>:<port>/ -o <filename> -L <link>