php如何用代理访问网站 求代码

php如何用代理访问网站 求代码
CURL的试过了 不行

CURL 就可以啊!你的先自己开个http代理 。或者百度找一些http代理

然后在curl里面设置http代理就可以了。

function curl_string ($url,$user_agent,$proxy){       
       $ch = curl_init();
       curl_setopt ($ch, CURLOPT_PROXY, $proxy);
       curl_setopt ($ch, CURLOPT_URL, $url);
       curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent);
       curl_setopt ($ch, CURLOPT_COOKIEJAR, "c:\cookie.txt");//可删除
       curl_setopt ($ch, CURLOPT_HEADER, 1);
       curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
       curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
       curl_setopt ($ch, CURLOPT_TIMEOUT, 120);       
       $result = curl_exec ($ch);
       curl_close($ch);       
       return $result;

}
$content = "http://www.google.com";$user_agent = "Mozilla/4.0";$proxy = "http://192.11.222.124:8000";

温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网