我有这个代理地址:125.119.175.48:8909
如何使用cURL(如cURL http://www.example.com)执行HTTP请求,但指定我的网络的代理地址?
我有这个代理地址:125.119.175.48:8909
如何使用cURL(如cURL http://www.example.com)执行HTTP请求,但指定我的网络的代理地址?
当前回答
一般方法:
export http_proxy=http://your.proxy.server:port/
然后,您可以通过代理从(许多)应用程序连接。
而且,正如下面的评论,对于https:
export https_proxy=https://your.proxy.server:port/
其他回答
对于curl,您可以在~/中配置代理。curlrc (Windows上的_curlrc)文件通过添加代理值,语法为:
proxy = http://username:password@proxy-host:port
作为airween的补充,另一个好主意是将它添加到你的.bashrc中,这样你就可以从非代理环境切换到代理环境:
alias proxyon="export http_proxy='http://YOURPROXY:YOURPORT';export https_proxy='http://YOURPROXY:YOURPORT'"
alias proxyoff="export http_proxy='';export https_proxy=''"
WHERE YOURPROXY:YOURPORT就是你的ip和端口代理:-)。
然后,简单地做
proxyon
您的系统将开始使用代理,与之相反:
proxyoff
旋度vv -ksL“https://example.com”- x " http:// <代理>:< >港”
curl -x socks5://username:password@ip:port example.com
来自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.