// get a web page into an array and remove html
// file() returns an array, which you can then loop through
$fcontents = file ('http://www.php.net');
while (list ($line_num, $line) = each ($fcontents)) {
        // if preg_match the weather text you are looking for
        //      preg_replace any html markup with empty string here
}

http://www.php.net/manual/en/function.file.php

http://www.php.net/manual/en/function.preg-replace.php

-Ben

-----Original Message-----
From: Chris Aitken [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 17, 2001 2:51 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Extracting Data from a URL output


I have a bit of a question which ive tried to look into, but I cant seem to 
find the right commands to check into or what the best method of attack it.

Basically, I want to grab a URLs data, make the data a string (which im 
doing with fopen and fread).

But now I have the entire html as a string, Im confused as to how I best 
attack stripping just the data I need out of it. There is alot of stuff at 
the top of this particular page before the actual content starts.

Is there anyone who has some examples of how they have attacked this type 
of task, or even just point me in the direction of how to start ?

I have tried to utilise strstr() but because there is no real comon thread 
starting off the data I need, I cant really use it properly.


There is always a common word in the data (its a local weather output).

For example, today it was -

...size=4 color=white>Todays weather will be 28 degrees in
Sydney</font>......

with a whole bunch of other site crap up the top. What im trying to do is 
simple extract everything between the > and the < wherever the word weather 
appears (its the common word) and its totally baffling me.



Any help would be great.



Chers


Chris


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to