我有这个代理地址: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版本(curl 7.22.0)。但对我有用的是:
curl -x http://proxy_server:proxy_port --proxy-user username:password -L http://url
希望它能更好地解决问题!
其他回答
总结一下所有提到的答案:
curl -x http://<user>:<pass>@<proxyhost>:<port>/ -o <filename> -L <link>
根据您的工作场所,您可能还需要为curl指定-k或——insecure选项,以解决CA证书的潜在问题。
curl -x <myCompanyProxy>:<port> -k -O -L <link to file to download>
对于http代理隧道(TLS协议需要),您需要指定-p(即——proxytunnel)而不是-x。
关于代理的Curl帖子
代理隧道使用新的“CONNECT”关键字而不是修改过的“GET”关键字
这是节点http-proxy-中间件库所需要的。
只有当我使用wget时,我才得到一个线索。
来自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.
注意,如果你正在使用SOCKS代理,而不是HTTP/HTTPS代理,你将需要使用——socks5开关:
curl --socks5 125.119.175.48:8909 http://example.com/
还可以使用——socks5-hostname代替——socks5在代理端解析DNS。