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

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


当前回答

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

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

其他回答

来自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.

如果代理正在使用自动代理与PAC文件。我们可以从javascript和PAC URL中找到实际的代理。

如果代理需要认证,我们可以先使用普通的web浏览器访问网站,会弹出认证对话框。认证完成后,我们可以使用wireshark捕获发送到代理服务器的http包,从http包中,我们可以从http头:proxy - authorization中获取认证令牌

然后我们可以设置http_proxy环境变量,并在http报头中包括认证令牌:Proxy-Authorization

出口http_proxy = http://proxyserver:端口

curl -H "Proxy-Authorization: xxxx" http://targetURL

旋度vv -ksL“https://example.com”- x " http:// <代理>:< >港”

与代理认证我使用:

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

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

curl -x socks5://username:password@ip:port example.com