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

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


当前回答

上面的解决方案可能不适用于我自己尝试过的一些curl版本(curl 7.22.0)。但对我有用的是:

curl -x http://proxy_server:proxy_port --proxy-user username:password -L http://url

希望它能更好地解决问题!

其他回答

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

如果您只是为一次性命令设置代理,则不需要导出http[s]_proxy shell变量。如。

http_proxy=http://your.proxy.server:port curl http://www.example.com

也就是说,如果我知道我总是要使用代理,我更喜欢curl -x。

来自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.

旋度vv -ksL“https://example.com”- x " http:// <代理>:< >港”

根据您的工作场所,您可能还需要为curl指定-k或——insecure选项,以解决CA证书的潜在问题。

curl -x <myCompanyProxy>:<port> -k -O -L <link to file to download>