Fetching Data

This is exactly what I’m looking to do and I have php support. Could you please explain how I would fetch and parse the info I’m looking for? I know the page I want the info from, just not sure how to go about it.

A lot depends on what the data looks like, and if you have the ability to modify existing php code to get what you want.

If you have never used PHP before, this might be a learning curve.

First start out with what it is you are attempting to parse, the URL etc…

Something like?

http://www.carterlake.org/test.php

<?php

$hazardhtml = fetchUrlWithoutHanging('http://www.crh.noaa.gov/showsigwx.php?warnzone=MAZ012&warncounty=MAC027&local_place1=Milford&product1=Hazardous+Weather+Outlook');

		$NOAAHazard = explode("$$",$hazardhtml);
		$NOAAHazard = explode("THIS HAZARDOUS WEATHER OUTLOOK",$NOAAHazard[0]);
	if (strlen($NOAAHazard[1])>1) {
		$NOAAHazard[1] = 'THIS HAZARDOUS WEATHER OUTLOOK' . $NOAAHazard[1];
	} else {
		$NOAAHazard[1] = 'No Active Hazardous Weather In Our Area';
	}

function fetchUrlWithoutHanging($url)
   {
   // Set maximum number of seconds (can have floating-point) to wait for feed before displaying page without feed
   $numberOfSeconds=4;    

   // Suppress error reporting so Web site visitors are unaware if the feed fails
   error_reporting(0);

   // Extract resource path and domain from URL ready for fsockopen

   $url = str_replace("http://","",$url);
   $urlComponents = explode("/",$url);
   $domain = $urlComponents[0];
   $resourcePath = str_replace($domain,"",$url);

   // Establish a connection
   $socketConnection = fsockopen($domain, 80, $errno, $errstr, $numberOfSeconds);

   if (!$socketConnection)
       {
       // You may wish to remove the following debugging line on a live Web site
       // print("<!-- Network error: $errstr ($errno) -->");
       }    // end if
   else    {
       $xml = '';
       fputs($socketConnection, "GET $resourcePath HTTP/1.0\r\nHost: $domain\r\n\r\n");
   
       // Loop until end of file
       while (!feof($socketConnection))
           {
           $xml .= fgets($socketConnection, 128);
           }    // end while

       fclose ($socketConnection);

       }    // end else

   return($xml);

   }    // end function

?>

<pre>
<? echo $NOAAHazard[1]; ?>
</pre>


Should probably add caching but I was in a hurry… Rose Bowl is on. :wink:

What is so important about a bowl of flowers ??? :o :o :o :lol: :lol: :lol:

how are you getting on with WD there milfordwx?
still overwhelming, LOL?

Thats exactly what I’m looking for! I will play with it a bit tomorrow, thanks!

Brian, I’m doing well with WD, but I’m working my way through things. I am still having some issues with the import of the old data that I posted a few days ago, but the holidays have slowed things a bit for now.

Paul

I have the php running fine as a page itself (http://www.pdfamily.com/weather/hazard.php) and I’m wondering if there is a way to get it to run on an html page, preferably within a table? What I’m looking to do is have the hazard outlook appear in the table I have the watches and warnings on my main page (http://www.pdfamily.com/weather/index.html), just in a different cell.
I’m new to php and appreciate any help.

Thanks!

Well, after some battles with my host I am able to run php within an html document and now I would like to run 2 or 3 php scripts on the same page, is this possible? I am looking to run a watch, short tern forecast and hazard outlook script all on the same page, but, when I try to, only the first one runs properly and the other 2 come back as false…?