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)
I am doing the following:
$url = "http://www.mydomain.com";
$html = file_get_contents($url);
$dom= new domDocument;
$dom->loadHTML($html);
And I am getting the following errors:
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
Somehow the likes are not shown? Also if I do something like this:
$url = "http://www.mydomain.com";
$html = file_get_contents($url);
echo $html;
preg_match_all(
'/<div id="LikePluginPagelet".*?>.*?<\/div>/s',
$html,
$posts,
PREG_SET_ORDER
);
print_r($posts)
The first 'echo' actually shows the whole page, but then the print_r just shows Array ( )
Is it possible that some things cannot be grabbed via php? Here is an example page: http://developers.facebook.com/docs/reference/plugins/like/
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.
Update:
Can you make code that will get the 500K number of likes from here by scraping the page? http://developers.facebook.com/docs/reference/plugins/like/ Or any other page that contains a number of likes, if I can get that I can use it in my code as well.
Thanks!