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

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


当前回答

对于curl,您可以在~/中配置代理。curlrc (Windows上的_curlrc)文件通过添加代理值,语法为:

proxy = http://username:password@proxy-host:port

其他回答

与代理认证我使用:

curl -x <protocol>://<user>:<password>@<host>:<port> --proxy-anyauth <url>

因为,我不知道为什么curl不使用/catch http[s]_proxy环境变量。

我喜欢用这个来获得我被看到的IP

curl -x http://proxy_server:proxy_port https://api.ipify.org?format=json && echo

希望这能帮助到一些人。

来自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指定-k或——insecure选项,以解决CA证书的潜在问题。

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

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