Home >Backend Development >PHP Tutorial >curl如何通过代理IP请求https网址

curl如何通过代理IP请求https网址

WBOY
WBOYOriginal
2016-06-06 20:27:015001browse

一、命令行:

<code>curl -x IP:PORT -k 'https://SITE'</code>

结果: curl: (56) Proxy CONNECT aborted

二、PHP代码

<code class="php">$ip = "IP:PORT";
$url = "https://SITE";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_PROXY, $ip);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
var_dump($output);</code>

结果:boolean(false)


RT,这个问题让我好头疼,网站没搜到资料,求问有什么方式可以实现我的需求吗?

回复内容:

一、命令行:

<code>curl -x IP:PORT -k 'https://SITE'</code>

结果: curl: (56) Proxy CONNECT aborted

二、PHP代码

<code class="php">$ip = "IP:PORT";
$url = "https://SITE";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_PROXY, $ip);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
var_dump($output);</code>

结果:boolean(false)


RT,这个问题让我好头疼,网站没搜到资料,求问有什么方式可以实现我的需求吗?

参考 so 上这两篇文章提供的方法

curl-https-through-a-proxy
linux-curl-command-with-proxy

装个proxychains,如果是见不得光的,可以用ss+arm-tor

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn