直接上最简单的代码
//1. 初始化
$curl = curl_init();
$url = 'http://www.baidu.com';
//2. 设置curl的参数
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//3. 采集
$output = curl_exec($ch);
//4. 销毁
curl_close($ch);
//5.保存demo.html到本地
file_put_contents('./demo.html', $output);
复制代码