curl 使用 proxy (http_proxy, https_proxy)

第一种方法:定义环境变量

//无需用户名和密码
export http_proxy=http://ip:port
export https_proxy=http://ip:port

//需要用户名和密码
export http_proxy=http://user:password@ip:port
export https_proxy=https://user:password@ip:port

第二种方法:在执行curl时加参数-x

curl -x <[protocol://][user:password@]proxyhost[:port]> url
--proxy <[protocol://][user:password@]proxyhost[:port]> url
--proxy http://user:password@Your-Ip-Here:Port url
-x http://user:password@Your-Ip-Here:Port url


curl -x http://mike:123456@api.baidu.com:3392 https://www.zixi.org