curl_init Get 方式获取 HTML代码

<?php
echo "2015";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.baidu.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$output = curl_exec($ch);
curl_close($ch);
$html = htmlspecialchars($output); //该函数直接显示 HTML 代码 教程:http://blog.csdn.net/ximenxiafeng/article/details/12261091
$html = iconv("UTF-8","GB2312",$html); //将utf8转化为gb2312 教程:http://www.jb51.net/article/27743.htm
print_r($html);
?>

posted @ 2015-04-29 11:09  stma  阅读(760)  评论(0)    收藏  举报