本文翻译自:performing HTTP requests with cURL (using PROXY)
I have this proxy address: 125.119.175.48:8909
我有这个代理地址: 125.119.175.48:8909
: 125.119.175.48:8909
How can I perform a HTTP request using cURL like curl http://www.example.com
, but specifying the proxy address of my network? 如何使用curl http://www.example.com
等cURL执行HTTP请求,但是指定网络的代理地址?
#1楼
参考:https://stackoom.com/question/ddCb/使用cURL执行HTTP请求-使用PROXY
#2楼
The above solutions might not work with some curl versions I tried them for myself(curl 7.22.0). 上面的解决方案可能不适用于我自己尝试过的一些curl版本(curl 7.22.0)。 But what worked for me was: 但对我有用的是:
curl -x http://proxy_server:proxy_port --proxy-user username:password -L http://url
Hope it solves the issue better! 希望它能更好地解决问题!
#3楼
as an adition to airween, another good idea is to add this into your .bashrc, so you'll be able to switch from non proxied to proxied environment: 作为对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 is exactly that, your ip and port proxy :-). 你在哪里:YOURPORT就是这样,你的ip和端口代理:-)。
Then, simply doing 然后,干脆做
proxyon
your system will start to use the proxy, and just the opposite with: 你的系统将开始使用代理,而正好相反:
proxyoff
#4楼
Beware that if you are using a SOCKS proxy, instead of a HTTP/HTTPS proxy, you will need to use the --socks5
switch instead: 请注意,如果您使用的是SOCKS代理,而不是HTTP / HTTPS代理,则需要使用--socks5
开关:
curl --socks5 125.119.175.48:8909 http://example.com/
You can also use --socks5-hostname
instead of --socks5
to resolve DNS on the proxy side. 您还可以使用--socks5-hostname
而不是--socks5
来解析代理端的DNS。
#5楼
you can use : 您可以使用 :
curl http://www.example.com --proxy http://125.119.175.48:8909
as explained by Karl 正如卡尔所解释的那样
#6楼
use the following 使用以下内容
curl -I -x 192.168.XX:XX http://google.com
192.168.XX:XX
put your proxy server ip and port. 192.168.XX:XX
把您的代理服务器ip和端口。
-v
verbose mode it will give more details including headers and response. -v
verbose模式它将提供更多细节,包括标题和响应。