我使用了(proxy curl php)并将其与我的私人域名链接。但我有问题,当我用它来打开第一页时它的工作非常好但是当我在页面之间转换到其他页面时,代理curl php链接更改为原始网站链接。
如何为我要打开它的所有页面保留与代理curl php的链接?
$url = $_GET['url'];
$proxy_ip = "192.157.252.175";
$proxy_port = "8800";
$username = "";
$password = "";
$user_agent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36";
function get_page ( $url, $proxy_ip, $proxy_port, $username, $password, $user_agent, $timeout=20)
{
$curl = curl_init();
curl_setopt ($curl, CURLOPT_USERAGENT, $user_agent);
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($curl, CURLOPT_TIMEOUT, $timeout);
curl_setopt ($curl, CURLOPT_PROXYUSERPWD, $username.":".$password);
curl_setopt ($curl, CURLOPT_PROXY, $proxy_ip.":".$proxy_port);
curl_setopt ($curl, CURLOPT_URL, $url);
curl_setopt ($curl, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
curl_setopt ($curl, CURLOPT_HTTPPROXYTUNNEL, 0);
curl_setopt ($curl, CURLOPT_FOLLOWLOCATION, 1);
$html = curl_exec($curl);
$error = curl_error($curl);
curl_close($curl);
if(strlen($html) > 0){
return $html ;
} else {
return $error;
};
}
echo get_page ($url, $proxy_ip, $proxy_port, $username, $password, $user_agent);