我有这个代理地址:125.119.175.48:8909
如何使用cURL(如cURL http://www.example.com)执行HTTP请求,但指定我的网络的代理地址?
我有这个代理地址:125.119.175.48:8909
如何使用cURL(如cURL http://www.example.com)执行HTTP请求,但指定我的网络的代理地址?
当前回答
总结一下所有提到的答案:
curl -x http://<user>:<pass>@<proxyhost>:<port>/ -o <filename> -L <link>
其他回答
来自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模式,它将提供更多的详细信息,包括头和响应。
旋度vv -ksL“https://example.com”- x " http:// <代理>:< >港”
如果您只是为一次性命令设置代理,则不需要导出http[s]_proxy shell变量。如。
http_proxy=http://your.proxy.server:port curl http://www.example.com
也就是说,如果我知道我总是要使用代理,我更喜欢curl -x。
作为airween的补充,另一个好主意是将它添加到你的.bashrc中,这样你就可以从非代理环境切换到代理环境:
alias proxyon="export http_proxy='http://YOURPROXY:YOURPORT';export https_proxy='http://YOURPROXY:YOURPORT'"
alias proxyoff="export http_proxy='';export https_proxy=''"
WHERE YOURPROXY:YOURPORT就是你的ip和端口代理:-)。
然后,简单地做
proxyon
您的系统将开始使用代理,与之相反:
proxyoff