PHP를 사용하여 Facebook 웹 페이지를 다운로드하고 싶습니다. 나는 stream_context_create와 함께 file_get_contents를 시도했다. 나는 또한 컬을 시도했다. 그러나 페이스 북은이 메시지를 returing된다Facebook 페이지를 다운로드하는 방법?
업데이트 귀하의 브라우저 당신은 페이스 북에서 지원하지 않는 웹 브라우저를 사용하고 있습니다. 더 나은 환경을 얻으려면 다음 사이트 중 하나로 이동하여 브라우저의 최신 버전을 받으십시오.
누락 된 항목이 있습니까?
$url="https://www.facebook.com/media/set/?set=a.189662541197403.1073741845.188398434657147&type=1&l=a8755a774e";
$custom_headers = array();
$custom_headers[] = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
$custom_headers[] = "Pragma: no-cache";
$custom_headers[] = "Cache-Control: no-cache";
$custom_headers[] = "Accept-Language: en-us;q=0.7,en;q=0.3";
$custom_headers[] = "Accept-Charset: utf-8,windows-1251;q=0.7,*;q=0.7";
$ch = curl_init();
$useragent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1";
curl_setopt($ch, CURLOPT_USERAGENT, $useragent); // set user agent
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $custom_headers);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,20);
curl_setopt($ch, CURLOPT_TIMEOUT, 40); //timeout in seconds
$txResult = curl_exec($ch);
$statuscode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
print "$txResult";
어떤 부분 나는 희망
줄까? – jdero
Facebook은 주로 Javascript 및 AJAX에 의해 구동되는 동적 사이트입니다. 스크린 스크래핑을 사용하여이 작업을 수행하는 것이 매우 어려울 것입니다. – lonesomeday
'Firefox/9.0.1'는 약간 오래된 것 같습니다. 필자가 작성한 최신 버전은 22.0입니다. 아마도 그것은 페이스 북이 좋아하지 않는 것입니다 ... – legoscia