时间:2022-07-06加入收藏
代码经过测试,简单粗暴!<?php
$gourl = "https://www.bingdou.com.cn/";
$ch = curl_init();
$proxy = "ip:端口";
curl_setopt($ch, CURLOPT_URL, $gourl);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
//代理
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
//自定义header
$headers = array();
$headers["user-agent"] = 'User-Agent: 浏览器ua;';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
//自定义cookie
curl_setopt($ch, CURLOPT_COOKIE,'cookie内容');
curl_setopt($ch, CURLOPT_ENCODING, 'gzip'); //gzip
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 4);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
TGA: php