我正在尝试使用 PHP 从网站获取 HTML 源代码,我尝试了以下代码,它适用于google.com
其他网站,但不适用于facebook.com
我错过了什么?
<?php
$curl_handle=curl_init();
curl_setopt($curl_handle, CURLOPT_URL,'www.facebook.com');
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Mozilla/5.0');
$query = curl_exec($curl_handle);
curl_close($curl_handle);
$query = htmlentities($query);
echo $query;
?>