PHP简单HTML DOM解析器浏览器不支持(Facebook)

PHP简单HTML DOM解析器浏览器不支持(Facebook),php,html,facebook,simple-html-dom,Php,Html,Facebook,Simple Html Dom,我正在使用PHP简单HTML DOM解析器获取facebook相册的内容,只是问题再次出现,我需要更新我的浏览器 我的代码 include('simple_html_dom.php'); $html = file_get_html("https://www.facebook.com/pg/natgeo/photos/?tab=album&album_id=431705768950"); echo $html; 还这个 像这样做 $url = "https://www.facebook.

我正在使用PHP简单HTML DOM解析器获取facebook相册的内容,只是问题再次出现,我需要更新我的浏览器

我的代码

include('simple_html_dom.php');
$html = file_get_html("https://www.facebook.com/pg/natgeo/photos/?tab=album&album_id=431705768950");
echo $html;
还这个


像这样做

$url = "https://www.facebook.com/pg/natgeo/photos/?tab=album&album_id=431705768950";

$opts = array(
  'http'=>array(
    'header'=>"User-Agent:Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53\r\n"
  )
);

$context = stream_context_create($opts);
$html = file_get_html($url , false, $context);

这样做

$url = "https://www.facebook.com/pg/natgeo/photos/?tab=album&album_id=431705768950";

$opts = array(
  'http'=>array(
    'header'=>"User-Agent:Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53\r\n"
  )
);

$context = stream_context_create($opts);
$html = file_get_html($url , false, $context);

Facebook检测你的浏览器功能。从伪装你的用户代理开始,看看会发生什么。抓取Facebook页面是违反他们的ToS的。如果你想访问这类数据,那么就按照你应该的方式去做——使用他们的API。他们知道如何获取照片,并且可以在没有任何标记的情况下获取照片Facebook检测到你的浏览器功能。从伪装你的用户代理开始,看看会发生什么。抓取Facebook页面是违反他们的ToS的。如果你想访问这类数据,就按照你应该的方式去做——使用他们的API。他们知道如何获取照片,而且不需要任何代币