我有这个代理地址: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 <protocol>://<user>:<password>@<host>:<port> --proxy-anyauth <url>
因为,我不知道为什么curl不使用/catch http[s]_proxy环境变量。
其他回答
来自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.
一般方法:
export http_proxy=http://your.proxy.server:port/
然后,您可以通过代理从(许多)应用程序连接。
而且,正如下面的评论,对于https:
export https_proxy=https://your.proxy.server:port/
与代理认证我使用:
curl -x <protocol>://<user>:<password>@<host>:<port> --proxy-anyauth <url>
因为,我不知道为什么curl不使用/catch http[s]_proxy环境变量。
上面的解决方案可能不适用于我自己尝试过的一些curl版本(curl 7.22.0)。但对我有用的是:
curl -x http://proxy_server:proxy_port --proxy-user username:password -L http://url
希望它能更好地解决问题!
我喜欢用这个来获得我被看到的IP
curl -x http://proxy_server:proxy_port https://api.ipify.org?format=json && echo
希望这能帮助到一些人。