kla0005 Posted February 10, 2010 Share Posted February 10, 2010 Hello guys, someone who knows how i can get the source from .. google maybe? - with php, so i can get the whole google source in a variable? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/191652-get-source/ Share on other sites More sharing options...
jskywalker Posted February 10, 2010 Share Posted February 10, 2010 you can get source from google here: http://source.android.com/download no php needed. Quote Link to comment https://forums.phpfreaks.com/topic/191652-get-source/#findComment-1010239 Share on other sites More sharing options...
kla0005 Posted February 10, 2010 Author Share Posted February 10, 2010 you can get source from google here: http://source.android.com/download no php needed. What that? Somekind of program to Ubuntu? Ehm, i didnt mean it that way.. Cant i make a system that gets thé source from everypage? If im making an input field in a form and postes for example 'http://javascript.com', then il' get the html source from the page in a variable? Quote Link to comment https://forums.phpfreaks.com/topic/191652-get-source/#findComment-1010242 Share on other sites More sharing options...
DWilliams Posted February 10, 2010 Share Posted February 10, 2010 You can open a socket on port 80 to make the target's webserver send you the page source. For example: <?php $website = "phpfreaks.com"; $fp = fsockopen ($website, 80); if ($fp) { fwrite($fp, "GET / HTTP/1.1\r\nHOST:$website\r\n\r\n"); while (!feof($fp)) { print fread($fp,256); } fclose ($fp); } else { print "Fatal error\n"; } ?> That code should print out the source of whatever URL the $website variable is set to. For more information read the excellent socket guide at http://tuxradar.com/practicalphp/15/1/0 . That code I posted is from there mostly Quote Link to comment https://forums.phpfreaks.com/topic/191652-get-source/#findComment-1010249 Share on other sites More sharing options...
wildteen88 Posted February 10, 2010 Share Posted February 10, 2010 Sockets is one way, an alternative is to use file_get_contents. Eg $HTML_Source = file_get_contents('http://somesite.com'); echo '<textarea>'.$HTML_Source.'</textarea>'; Quote Link to comment https://forums.phpfreaks.com/topic/191652-get-source/#findComment-1010254 Share on other sites More sharing options...
mikesta707 Posted February 10, 2010 Share Posted February 10, 2010 As long as we are posting alternatives, here is another, using the Curl library. function getRawHtml($webpage){ $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $webpage); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); $stuff = curl_exec($curl); return $stuff; } by the way, you can't get the PHP when doing either of these. You only get the HTML that the PHP (or other server side language) generates. You can't get the PHP, and frankly, thats theft. If people could just steal other sites PHP (basically the stuff that makes the site a good site) dont you think we'd be seeing a lot of facebook /google clones out there? Quote Link to comment https://forums.phpfreaks.com/topic/191652-get-source/#findComment-1010261 Share on other sites More sharing options...
Maq Posted February 10, 2010 Share Posted February 10, 2010 Hi kla0005, If you could provide a bit more detail about what you're trying to accomplish, it would be easier for us to give you a more detailed and solid solution. Quote Link to comment https://forums.phpfreaks.com/topic/191652-get-source/#findComment-1010267 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.