note 7986 deleted from features.remote-files by irc-html

From: Date: Sat, 19 Jan 2002 20:40:44 +0000
Subject: note 7986 deleted from features.remote-files by irc-html
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-25411@lists.php.net to get a copy of this message
Here's how to get the html from a page that requires a cookie: $connection = fsockopen ('www.php.net', 80, &$errorNumber, &$errorString, 10); if ($connection) { //set non-blocking mode set_socket_blocking($connection, false); //tell server what document we want fputs ($connection, "GET /quickref.php HTTP/1.0"); fputs ($connection, "\r\n"); fputs ($connection, "Cookie: PUT_YOUR_COOKIES_HERE"); fputs ($connection, "\r\n\r\n"); $headerStart = 0; $headerEnd = 0; while (!feof($connection)) { $currentLine = fgets ($connection, 128); if ($headerEnd) { //this is the html from the page echo $currentLine; } else if ( ereg("^HTTP", $currentLine) ) { //came to the start of the header $headerStart = 1; } else if ( $headerStart && ereg("^[\n\r\t ]*$", $currentLine) ) { //came to the end of the header $headerEnd = 1; } else { //this is the header, if you want it... } } fclose ($connection); } else { echo "$errstr ($errno)<br>\n"; } (remove NO SPAM to get my email address)

« previous php.notes (#25411) next »