php使用curl请求数据(采集数据)

 <?php

 $url = "http://www.baidu.com/s?wd=刘俊涛的博客";

 $header = array(
'User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36',
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// 执行
$content = curl_exec($ch);
if ($content == false) {
echo "error:" . curl_error($ch);
}
// 关闭
curl_close($ch); //输出结果
echo ($content);
上一篇:Android蓝牙传感应用


下一篇:[Algorithm] Bitwise Operators