RE: trying to capture url data to a stream, with atwist...

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

 



ronan, thanks so much for the assist, it works like a champ!

thanks

green

-----Original Message-----
From: Ronan Chilvers [mailto:ronan@thelittledot.com]
Sent: Friday, May 23, 2003 9:33 AM
To: php-db@lists.php.net
Subject: Re:  trying to capture url data to a stream, with
atwist...
Importance: High


Hi Andy

Try this one using fsockopen...

function random_website()
{
	$site = "random.yahoo.com";
	$page = "/fast/ryl";
	$open = fsockopen($site, 80, $errno, $errstr);
	if ($open) {
		fputs($open, "GET $page HTTP/1.0\r\n\r\n");
		$data = "";
		while (!feof($open)) {
			$data .= fgets($open,1000);
		}
		fclose($open);
	} else {
		echo "No Socket<BR>";
	}
	$search = ereg("Location: (.*)", $data, $content);
	return $content[1];
}

Seems to do the trick ...

:-)

Ronan
e: ronan@thelittledot.com
t: 01903 739 997
w: www.thelittledot.com

The Little Dot is a partnership of
Ronan Chilvers and Giles Webberley


On 23 May,2003 at  3:48 Andy Green wrote:

> 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