2 回答
TA贡献1921条经验 获得超9个赞
不要用file_get_contents函数。
用snoopy的类,网上有snoopy.class.php,你自行百度查找。
snoopy的类可以设置$proxy_host参数,设置代理主机,$proxy_port是代理主机端口。你下载一个下来,网上的教程很多,看看应该明白。
TA贡献2080条经验 获得超4个赞
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; } $url_page = "http://www.baidu.com";$user_agent = "Mozilla/4.0";$proxy = "http://192.11.222.124:8000";//这里是http代理$string = curl_string($url_page,$user_agent,$proxy);echo $string;
- 2 回答
- 0 关注
- 156 浏览
添加回答
举报
