Jump to content

Recommended Posts

Hi!

 

I am working on a web page running a php script to extract from another website water temperatures from around the area.  I have been working on this for about a month, and dont know how to do this. 

 

Here is where I am trying to grab the data from: http://www.lrn.usace.army.mil/pao/lakeinfo/CEN.htm

---------------------------------------------------------------------------------

This is the data I need to obtain:

 

Fishing is reported to be fair.  Bass are being caught on spinnerbaits, plastic worms and jigs. Some Crappie are being caught on jigs and minnows. Trout are being taken in the tailwater area.

 

The lake elevation is 633.87 feet above mean sea level.  The water temperature is 58.0 degrees on the surface, 50.0 degrees at 10 feet.  Ensure all required safety equipment is onboard your boat and in workable condition.

 

I am wanting to do this for a couple of other lakes with the same data format.

 

Can anyone help?

 

Thanks in advance!

Mike

$html = file_get_contents('http://www.lrn.usace.army.mil/pao/lakeinfo/CEN.htm');
preg_match('~The water temperature is ([\d]{1,2}.[\d]{1,2}) degrees~', $html, $match);
echo $match[1];

 

Something like that should work.

I'm not going to write all the code for you. The example I showed was to point you in the right direction. I'm glad to help if you are stuck, though. Look up web scraping, and get comfortable writing RegEx.

Hi!

 

Again, thank you for you kind help on this!  I did not even know that it was called web scrapping!  :)  Easy enough.

 

Well here is what I have done to make things work on my end:

 

  <?php

//old Hickory

$deg = ('°');

$html = file_get_contents('http://www.fishingnotes.com/lakeinfo.php?id=27931');

preg_match('~Est Water Temperature.*?([\d]{1,2}).&?deg.*?<br><br>~', $html, $match);

echo $match[1];

echo $deg;

 

 

?>

 

Gonna add a few more features to color code temperatures.  Should be fun.

 

Thank you again.  I really do appreciate your help on this.  You have taught me a couple of things.

 

Mike

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.