Forum Moderators: coopster

Message Too Old, No Replies

Extracting Data from HTML

How to Extract Flash Weather warning from Met

         

lupatis

5:37 pm on Nov 19, 2005 (gmt 0)

10+ Year Member



Hi there,

I am trying to scan a Met office webpage to see if any Flash Weather warning exist for my region. The following is an extract from the UK Met Office Page in question....
//Start Snip
<p>These warnings are issued to help the public make informed
decisions that protect their life, welfare and property
in the event of severe weather in the next few hours.
They are issued when fixed weather thresholds are met.</p>

No severe weather is expected in the next few hours.

<br><br>
//End

So far I have opened a socket and tried the following ...

preg_match("thresholds are met.<\/p>(.*)<br><br>", $read,$output);

but it does not work ;-) I have also tried to use eregi but no luck.

All I am trying to do is determine if a warning exists, a true/flase would be all I need to trigger existing functions.

Can anyone help or preferably point me to a idiots guide to regex, I am an amateur coder and REGEX is the my main stumbling block with php.

Many thanks ;-)

Mike

directrix

10:38 pm on Nov 19, 2005 (gmt 0)

10+ Year Member



Do you need to use regular expressions here? Would something like the following work?

if (strpos($read, 'No severe weather is expected in the next few hours.') === false) {
// Weather warning in effect...
} else {
// No severe weather warning...
}

lupatis

3:30 am on Nov 20, 2005 (gmt 0)

10+ Year Member



Many thanks, works perfectly.

I'll broaden my statement - it's not just REGEX thats my down fall ;)))

Mike