Log in

View Full Version : facebook give default page source when i fetched it with php



mayanktalwar1988
04-27-2010, 02:04 AM
when ever i try to read facebook page source they give some default page source

the title of default page stATES Incompatible Browser | Facebook..but the original title of index page is welcome to facebooK

the code used by me is this


<?php
$url = "http://www.facebook.com";
$str = file_get_contents($url);

echo '<pre>';
echo htmlentities($str);
?>

its seems like facebok is blocking this type of interaction..if that is the case then is there any other way to get facebook page source out .......because i have treid it on other site
it works ok for it

traq
04-27-2010, 03:03 AM
Sound like (don't know for sure) it's redirecting you because it recognizes that it's a script (and not a browser) accessing the page.

What are you trying to do, exactly?

is there any other way to get facebook page source out...
If you're just interested in what it looks like, you could always visit the page and right-click.

djr33
04-27-2010, 04:39 AM
I agree completely. It's very likely that you are violating either terms of service at facebook or just running into security precautions. If you really work around it you might be able to get a semi-working script, but what's the point? They'll probably block it after they notice what you're doing unless you're just doing this once or something.
Due to the nature of the request, this is not the type of question we answer here.
Note that facebook has some APIs available if you want to work with it. Check out their info.

mayanktalwar1988
04-27-2010, 12:18 PM
i just learning and figuring out things which would help me to make a crawler for a site....just started...

traq
04-27-2010, 02:03 PM
Why do you need a crawler? What are you trying to accomplish?

If you're "just learning," it's better to look at a page that has something you like, right-click, and find the appropriate code to "figure things out."

djr33
04-27-2010, 05:32 PM
It'll be complex to make a crawler. Why not start on sites (like your own, for an easy example) that don't block this sort of thing? Then once you've worked out all the details you can figure out how to make it work for the sites that aren't so easy.
But again, be careful with how you approach all of this.