DEMO代码示例-PHP

更新时间:2020-07-04 09:17
    // 要访问的目标网址
$targetUrl = "http://baidu.com" ;

// 代理服务器
$proxyServer = "http://ip:port"; //IP和端口号

// 隧道身份信息
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $targetUrl);

curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, false);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

// 设置代理服务器
// curl_setopt($ch, CURLOPT_PROXYTYPE, 0); //http

curl_setopt($ch, CURLOPT_PROXYTYPE, 5); //sock5

curl_setopt($ch, CURLOPT_PROXY, $proxyServer);

// 设置隧道验证信息
curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);

curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727;)");

curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);

curl_setopt($ch, CURLOPT_TIMEOUT, 5);

curl_setopt($ch, CURLOPT_HEADER, true);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$result = curl_exec($ch);

curl_close($ch);

var_dump($result);

 

本文导读

客户热线:4008765417