468,257 Members | 1,415 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,257 developers. It's quick & easy.

Reading from a Dynamic Page

Hi,

Currently I need to read contents from a dynamic page, which goes
something like:
http://servername/filename.jsp?arg1=a&arg2=b

The content is not static, neither is there a file for me to read
from. Thus, I would like to know how could I accomplish this task in
php. I saw from forums, there is a similar implementation of the RSS
reader which reads it in the following way:

$fileName = url;

$data = implode("", file($fileName));
....

Will I be able to do the same thing?

I am rather new to php, so would appreciate any help rendered. Thanks!

May 18 '07 #1
5 2413
At Fri, 18 May 2007 02:49:07 -0700, ycquak let his monkeys type:
Hi,

Currently I need to read contents from a dynamic page, which goes
something like:
http://servername/filename.jsp?arg1=a&arg2=b

The content is not static, neither is there a file for me to read from.
Thus, I would like to know how could I accomplish this task in php. I
saw from forums, there is a similar implementation of the RSS reader
which reads it in the following way:

$fileName = url;

$data = implode("", file($fileName)); ...

Will I be able to do the same thing?

I am rather new to php, so would appreciate any help rendered. Thanks!
You can open a webpage using file() if your server allows opening remote
files, but AFAIK parsing the variables like this isn't gonna work. Instead
you probably want to use cURL to send the right http-request.

Side note: implode("", file($filename)) can be replaced with
file_get_contents($filename), which reads the file into a string directly.

Sh.
May 18 '07 #2
yc
Hi,

I did a search of curl. It seems that my host doesn't support the
usage of curl. In this case, is there any other workaround? Am I able
to retrieve the data from this remote site and then save it to a file,
and read from it? Thanks!

yc

On May 18, 8:23 pm, Schraalhans Keukenmeester <inva...@invalid.spam>
wrote:
At Fri, 18 May 2007 02:49:07 -0700, ycquak let his monkeys type:
Hi,
Currently I need to read contents from a dynamic page, which goes
something like:
http://servername/filename.jsp?arg1=a&arg2=b
The content is not static, neither is there a file for me to read from.
Thus, I would like to know how could I accomplish this task in php. I
saw from forums, there is a similar implementation of the RSS reader
which reads it in the following way:
$fileName = url;
$data = implode("", file($fileName)); ...
Will I be able to do the same thing?
I am rather new to php, so would appreciate any help rendered. Thanks!

You can open a webpage using file() if your server allows opening remote
files, but AFAIK parsing the variables like this isn't gonna work. Instead
you probably want to use cURL to send the right http-request.

Side note: implode("", file($filename)) can be replaced with
file_get_contents($filename), which reads the file into a string directly.

Sh.

May 19 '07 #3
At Fri, 18 May 2007 21:04:21 -0700, yc let his monkeys type:
Hi,

I did a search of curl. It seems that my host doesn't support the
usage of curl. In this case, is there any other workaround? Am I able
to retrieve the data from this remote site and then save it to a file,
and read from it? Thanks!

yc
http://pear.php.net/package/HTTP_Client may help you (if PEAR is supported
by your host.)

Sh.
May 19 '07 #4
yc****@gmail.com wrote:
Hi,

Currently I need to read contents from a dynamic page, which goes
something like:
http://servername/filename.jsp?arg1=a&arg2=b

The content is not static, neither is there a file for me to read
from. Thus, I would like to know how could I accomplish this task in
php. I saw from forums, there is a similar implementation of the RSS
reader which reads it in the following way:

$fileName = url;

$data = implode("", file($fileName));
...

Will I be able to do the same thing?

I am rather new to php, so would appreciate any help rendered. Thanks!
You don't simply try it

echo file_get_contents("http://www.google.com/search?q=blah");

what does this do?

--
gosha bine

extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok
May 19 '07 #5
At Sat, 19 May 2007 13:24:04 +0200, gosha bine let his monkeys type:
yc****@gmail.com wrote:
>Hi,

Currently I need to read contents from a dynamic page, which goes
something like:
http://servername/filename.jsp?arg1=a&arg2=b

The content is not static, neither is there a file for me to read
from. Thus, I would like to know how could I accomplish this task in
php. I saw from forums, there is a similar implementation of the RSS
reader which reads it in the following way:

$fileName = url;

$data = implode("", file($fileName));
...

Will I be able to do the same thing?

I am rather new to php, so would appreciate any help rendered. Thanks!

You don't simply try it

echo file_get_contents("http://www.google.com/search?q=blah");

what does this do?
My bad Gosha, I suggested he couldn't. The fact I hadn't ever tried it
doesn't always mean it's not possible. Never too old to learn from my
mistakes...

Sh.

May 19 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Marc | last post: by
1 post views Thread by Roger Godefroy | last post: by
7 posts views Thread by Abraham Luna | last post: by
reply views Thread by Mike Collins | last post: by
10 posts views Thread by jflash | last post: by
5 posts views Thread by pittendrigh | last post: by
9 posts views Thread by pbd22 | last post: by
reply views Thread by kermitthefrogpy | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.