curl伪造user_agent的方法

2016-04-08 16:58:00
1147533288
原创
6679
不解释,直接用。

function curl_get_file_contents($URL)
{
    $c = curl_init();
    curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($c, CURLOPT_HEADER, 1);//输出远程服务器的header信息
    curl_setopt($c, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727;http://www.9qc.com)');
    curl_setopt($c, CURLOPT_URL, $URL);
    $contents = curl_exec($c);
    curl_close($c);
    if ($contents) {return $contents;}
    else {return FALSE;}
}
$urldata=curl_get_file_contents('http://www.oschina.net/code/list');
$fp = @fopen("Log.html", "w"); //记录捕获到的页面源码
fwrite($fp,$urldata);
fclose($fp);
echo '记录完成,<a href="Log.html">查看捕获结果</a>';

文章分类
联系我
联系人: meepo
电话: *****
Email: 1147533288@qq.com
QQ: 1147533288