使用cURL执行HTTP请求(使用PROXY)

本文翻译自:performing HTTP requests with cURL (using PROXY)

I have this proxy address: 125.119.175.48:8909 我有这个代理地址: 125.119.175.48:8909125.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模式它将提供更多细节,包括标题和响应。

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值