Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/191652-get-source/#findComment-1010242
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/191652-get-source/#findComment-1010249
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/191652-get-source/#findComment-1010261
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.