Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP: Getting url of facebook likes
    primarykey
    data
    text
    <p>I am trying to get information on the likes of the page, since I want to order the posts of my site by likes. I decided to do it by scraping the page, and store the likes of each post id in db, then I can just order using the db. (I can run this 'scraper' every hour or something like that to update the results)</p> <p>I am doing the following: </p> <pre><code> $url = "http://www.mydomain.com"; $html = file_get_contents($url); $dom= new domDocument; $dom-&gt;loadHTML($html); </code></pre> <p>And I am getting the following errors:</p> <pre><code>Notice: DOMDocument::loadHTML() [domdocument.loadhtml]: Namespace prefix fb is not defined in Entity, line: 36 in C:\xampp\htdocs\page.php on line 13 Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Tag fb:like invalid in Entity, line: 36 in C:\xampp\htdocs\page.php on line 13 </code></pre> <p>Somehow the likes are not shown? Also if I do something like this:</p> <pre><code> $url = "http://www.mydomain.com"; $html = file_get_contents($url); echo $html; preg_match_all( '/&lt;div id="LikePluginPagelet".*?&gt;.*?&lt;\/div&gt;/s', $html, $posts, PREG_SET_ORDER ); print_r($posts) </code></pre> <p>The first 'echo' actually shows the whole page, but then the print_r just shows <code>Array ( )</code> </p> <p>Is it possible that some things cannot be grabbed via php? Here is an example page: <a href="http://developers.facebook.com/docs/reference/plugins/like/" rel="nofollow">http://developers.facebook.com/docs/reference/plugins/like/</a></p> <p>You can see that where the like is and the number of likes, the div has id 'LikePluginPagelet', but PHP does not obtain the stuff inside it.</p> <p>Update:</p> <p>Can you make code that will get the 500K number of likes from here by scraping the page? <a href="http://developers.facebook.com/docs/reference/plugins/like/" rel="nofollow">http://developers.facebook.com/docs/reference/plugins/like/</a> Or any other page that contains a number of likes, if I can get that I can use it in my code as well.</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload