 |
 |
 |
 |
#227647 - 11/10/02 09:04 PM
data retrieval - public domain
|
Enthusiast
Registered: 06/19/02
Posts: 307
Loc: Fernandina Beach, FL
|
I'm working on a script which pulls tide data from NOAA, parses it and the inserts into my PAL page. You can see it working at http://www.fish-tails.net<br /><br />Anyway, I need a little help on regexp, and maybe some suggestions.<br /><br />Ideally, I would like to pull the data from NOAA, strip html completely out, and then insert the data into mysql. Once the data is stored, I can then write a script so that the user can select the reference stations they want to be displayed on the home page, or in their My Home.<br /><br />Currently, I have it loading directly to the home page without stripping html. Here is the code I'm using.<br /><br /> <pre><font class="small">code:</font><hr> <br />$month = date("n");<br />$day = date("j");<br />$year = date("Y");<br />$next = (date("j")+1);<br />$next1 = $next+1;<br />$next2 = $next1+1;<br />$next3 = $next2+1;<br />$tide1 = "$month/$day/$year";<br />$tide2 = "$month/$next/$year";<br />$tide3 = "$month/$next1/$year";<br />$tide4 = "$month/$next2/$year";<br />$tide5 = "$month/$next3/$year";<br /><br />//$url = 'http://www.co-ops.nos.noaa.gov/tides/seFB.html';<br />$url = 'http://co-ops.nos.noaa.gov/tides/get_pred.shtml?stn=0030+Fernandina+Beach&secstn=Simpson+Creek,<br />+A1A+highway+bridge&thh=+0&thm=05&tlh=+0&tlm=1<br />9&hh=*0.84&hl=*0.65';<br /><br />$lines_array = file($url);<br /><br />$lines_string = implode('', $lines_array);<br />eregi("$tide1(.*)$tide5", $lines_string, $head);<br />//eregi("<BODY BGCOLOR=\"#FFFFFF\">(.*)</body>", $lines_string, $head);<br />//eregi("<pre>(.*)</pre>", $lines_string, $head);<br /><br />//$head = eregi_replace("</tr><tr><td align=\"right\" width=\"60\">$tide5</td></tr>", "</tr>", $head);<br /><br /><br /><br />echo "I'm running some tests now on the tides program I'm writing. Please use these with discretion. Thanks. DATA from NOAA";<br />echo "<br><b>Simpson Creek, A1A highway bridge 2002 Water Level Predictions</b>";<br />echo "<br>(Reference station - Fernandina Beach)";<br />echo "<br>Corrections - Time Diff. (High 0 hr. 05 min. Low 0 hr. 19 min.)";<br />echo "<br>Hgt. Diff. (High *0.84 Low *0.65)";<br />echo "<br>All times listed are in Local Time, and all heights are in Feet referenced to Mean Lower Low Water (MLLW).";<br />echo "<br><hr><table><tr>";<br />echo "<th width=\"60\">Date</th><th width=\"60\">Time</th><th></th><th width=\"40\">Ht.</th><th> <br /></th><th>Time</th><th></th><th width=\"40<br />\">Ht.</th><th> <br /></th><th>Time</th><th></th><th width=\"40<br />\">Ht.</th><th> <br /></th><th>Time</th><th></th><th width=\"40<br />\">Ht.</th></tr><tr><td>";<br /><br />echo "<font face='arial'>";<br /><br /><br />echo $head[0];<br /><br /><br />echo "</td></tr></table>";<br /> </pre><hr> <br /><br />You will note I have two $url with one commented out. The one that is commented is the one I think woul be the easiest to work with, but then I'm not sure, which is why I'm here. <img src="/forum/images/graemlins/wink.gif" alt="" /><br /><br />The second one is the one that I'm using on my home page. Now, first off, I only want 4 days displayed, but if you look at my home page a new line with a fifth day starts. I've tried preg_replace and ereg_replace but to no avail. Anyone have a good understanding of regexp that can help me out?<br /><br />Regarding the database. Looking for suggestions here. Should I set up a cron (I have an idea what it does but have never used it) to pull the data I want nightly, insert it into a db as one record, then have my pal box pull from that record? I would think that way there would be faster page load times. I'm open for suggestions here.<br /><br />Any help is appreciated.
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#227671 - 12/13/03 10:47 PM
Re: data retrieval - public domain
[Re: sf49rminer]
|
Junior Member
Registered: 01/31/02
Posts: 676
|
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#227673 - 12/25/03 12:10 AM
Re: data retrieval - public domain
[Re: ]
|
Junior Member
Registered: 01/31/02
Posts: 676
|
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#227680 - 01/12/04 07:12 PM
Re: data retrieval - public domain
[Re: Kelly]
|
Enthusiast
Registered: 06/19/02
Posts: 307
Loc: Fernandina Beach, FL
|
Um, yeah, I forgot. It's done. I've got it running out of a database, i.e. first you extract the data from NOAA, insert it into a database. Then your script pulls it from the database so it's tons faster. No need for cron because the tide predictions are done from certain 'harmonic constants' , so basically no matter when you go to NOAA and get tidal predictions, they are the same each time you go because they are using the same 'hc's' each time. So, you can get the tides and insert them into a db one time during the year, and just check them occasionally to ensure that the data matches what you have with what NOAA has.<br /><br />You can see the working version of the 'Tide Sticker' at http://www.fish-tails.net in the left hand column. It's not in a pal bax because I'm currently not using IIP for my home page due to some weird problems. However, it's just a matter of inserting the code into a cusompalbox. You can see it working in a pal box at http://www.fish-tails.net/index3.php (the one that was giving me problems and suddenly is working again). That's IIP 5.3.1, but it shouldn't matter which IIP you're using since it's just basic php code added to a a pal box.<br /><br />I also have a calendar running at http://www.fish-tails.net/threads/tidecal.php , which has a drop down box to grab the station for where ever you want and displays it in calendar format. It pulls from the same tables as the Tide Sticker. Though it is working flawlessly, there is some code cleanup I want to do for the calendar.<br /><br />I know you want the Tide Sticker. Send me a PM with an email and I'll send you the scripts as soon as I do some cleanup. There is one file for getting the data and inserting into a table. The other script is for the Tide Sticker itself. Once you've installed them and you fel like it's worth something to you, you can let me know and I'll give you my paypal address.<br /><br />If you want the calendar as well, that can be dones as well, but as I stated, I need to do some definite code cleanup for that. Let me know if you want that one as well, but I need more time to clean it up.<br /><br />Please keep in mind that I have many Florida fishing sites that would love to have my site go belly up, but they want my tides calendar and sticker really bad. Plus, they're trying to figure out how I've got weather (integrated with threads) on my site as well (members only feature). So, with that being said, you must agree NOT to divulge any of the code for either the tides calendar or the sticker to anyone. I am hoping that one of the big players (no names but they have some big fishing publications out, as well as big fishing sites) might see my scripts valuable, which would equate to a big "Fish ON!" inangling terms. <img src="http://www.ubbdev.com/forum/images/graemlins/laugh.gif" alt="" /><br /><br />Anyway, send me an email in the PM. I'll get it to you soon as I can.<br /><br />Tight Lines and either fish or cut bait! <img src="http://www.ubbdev.com/forum/images/graemlins/wink.gif" alt="" />
|
|
Top
|
|
|
|
 |
 |
 |
 |
|
|