Re: trying to capture url data to a stream, with a twist...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



function random_website()
{
    $site = "http://random.yahoo.com/fast/ryl";;
    $open = fopen($site, "r");
    $search = fread($open, 50000);
    fclose($open);
    $search = ereg("Location: (.*)", $search, $content);
    if ( $content[i] == "HTTP 301..." )
    {
        $httpRef = substr( $content[i], 0, x );    //x is the length of the HTTP
301 Error message
        $content[i] = substr_replace( $content[i], $httpRef, 0 );
    }
    return $content[1];
}

Edward Dudlik
Becoming Digital
www.becomingdigital.com


----- Original Message -----
From: "Andy Green" <_agreen@bellsouth.net>
To: <php-db@lists.php.net>
Sent: Friday, 23 May, 2003 03:48
Subject:  trying to capture url data to a stream, with a twist...


i'm trying to capture output from a remote url(random.yahoo.com/fast/ryl)
and use it on my site.  however, the remote url output always leads with a
Status 301 code, then outputs the data i want.  as a result, the fopen()
function thinks that the connection to the remote url fails, and goes no
further.

below is the code snippet i'm using to try and capture the stream, to no
avail...

function random_website()
     {

          $site = "http://random.yahoo.com/fast/ryl";;
          $open = fopen($site, "r");
          $search = fread($open, 50000);
          fclose($open);
          $search = ereg("Location: (.*)", $search, $content);
          return $content[1];
     }

ultimately, what i want is the data given after the 301 code, which is a
random url generated when you load the remote url.

any thoughts or suggestions are welcome.

thanks

green



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux