Scrape Facebook fanpage without API and get HTML content.
Hello there, the code below can be used to scrape any Facebook fanpage using CURL and there is no API credentials needed. Of course the fanpage has to be public as most are.
-------------------
Output - Not everything pasted here but just to show you.
<!DOCTYPE html> <html lang="en" id="facebook" class="no_js"> <head><meta charset="utf-8" /><meta name="referrer" content="default" id="meta_referrer" /><script>window._cstart=+new Date();</script><script>function envFlush(a){function b(b){for(var c in a)b[c]=a[c]}window.requireLazy?window.requireLazy(["Env"],b):(window.Env=window.Env||{},b(window.Env))}envFlush({"ajaxpipe_token":"AXikncviEy6Po_pv","timeslice_heartbeat_config":{"pollIntervalMs":33,"idleGapThresholdMs":60,"ignoredTimesliceNames":{"requestAnimationFrame":true,"Event listenHandler mousemove":true,"Event listenHandler mouseover":true,"Event listenHandler mouseout":true,"Event listenHandler scroll":true},"isHeartbeatEnabled":true,"isArtilleryOn":false},"shouldLogCounters":true,"timeslice_categories": ... e.t.c
<?php $fanPageName = "DisneyTheLionKing"; $ch = curl_init("http://www.facebook.com/".$fanPageName); curl_setopt( $ch, CURLOPT_POST, false ); curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true ); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7"); curl_setopt( $ch, CURLOPT_HEADER, false ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); $data = curl_exec( $ch ); echo htmlentities($data);
-------------------
Output - Not everything pasted here but just to show you.
<!DOCTYPE html> <html lang="en" id="facebook" class="no_js"> <head><meta charset="utf-8" /><meta name="referrer" content="default" id="meta_referrer" /><script>window._cstart=+new Date();</script><script>function envFlush(a){function b(b){for(var c in a)b[c]=a[c]}window.requireLazy?window.requireLazy(["Env"],b):(window.Env=window.Env||{},b(window.Env))}envFlush({"ajaxpipe_token":"AXikncviEy6Po_pv","timeslice_heartbeat_config":{"pollIntervalMs":33,"idleGapThresholdMs":60,"ignoredTimesliceNames":{"requestAnimationFrame":true,"Event listenHandler mousemove":true,"Event listenHandler mouseover":true,"Event listenHandler mouseout":true,"Event listenHandler scroll":true},"isHeartbeatEnabled":true,"isArtilleryOn":false},"shouldLogCounters":true,"timeslice_categories": ... e.t.c
Thanks for delivering a good stuff, Explanation is good, Nice Article.
ReplyDeletePython Online Training in Hyderabad
Python Training in Hyderabad
Python Training
Python Online Training
Its very informative blog and useful article thank you for sharing with us
ReplyDeleteIdenisyss Software Solutions is the best software development company in India that helps to build robust, secure & scalable software. We have 10+ years of experience and over 2000+ projects delivered.
Web Development Company India
Digital Marketing Services in India
Best Web Design Company in India
Mobile App Development Services in India