On Tue, 3 Aug 2004 20:00:56 -0400, Richard Bewley <[EMAIL PROTECTED]> wrote:
> Hi,
> I am trying to do some work that involves parsing through the HTML of
> some webpages. But, I cannot find an easy way in PHP to actually get that
> HTML. Say, for example, I need the HTML returned from
> http://www.yahoo.com/, I tried doing an fopen(), but the only way I can do
> it is if I use passthru, or exec and use the linux wget, then use fopen() on
> that file. Does anyone know if there's an easy function or way of doing it?
> I essentially need to download the web file, and store the contents of it in
> a variable to manipulate with my program.
>
There are many ways to do this. The simplest is with the file
functions, such as fopen and file_get_contents:
$html = file_get_contents('http://www.yahoo,com');
These will only work if you have the fopen wrappers turned on in your php.ini.
If this won't work for you, I would suggest using PEAR's HTTP_Request.
http://pear.php.net/package/HTTP_Request
It's a package that implements all of that in PHP code with sockets.
It's also got lots of useful features. FYI, the HTTP_Client package is
based on HTTP_Request and can take care of cookies and such for you so
that it looks like a user ir browsing a site. :-)
If you are new to PEAR, please go to this page to learn about it and
how to install:
http://pear.php.net/manual/en/introduction.php
http://pear.php.net/manual/en/installation.php
--
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder
paperCrane --Justin Patrin--
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php