cooldude832 Posted February 16, 2008 Share Posted February 16, 2008 I have the page http://www.almanac.com/weatherhistory/oneday.php?number=725090&wban=14739&day=1&month=1&year=1946&searchtype=zip and I want to get the mean temperature as I change the year/month anyone know a fast way to retrive just that section what I got so far is <?php $year = 1946; while($year < 2009){ $month = 1; while($month < 13){ $page = "http://www.almanac.com/weatherhistory/oneday.php?number=725090&wban=14739&day=1&month="; $page .= $month; $page .= "&year="; $page .= $year; $page .= "&searchtype=zipx"; $data = file_get_contents($page); $month++; } $year++; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/91430-quick-way-to-get-this-data/ Share on other sites More sharing options...
laffin Posted February 17, 2008 Share Posted February 17, 2008 if u looked at the html coding for the page <p style="margin: 3px 0pt; font-size: smaller;">MEAN<br>TEMPERATURE</p> <b style="font-size: x-large;">30.9</b><b style="font-size: large; font-weight: normal;"><sup>°F</sup></b><br> <p style="margin: 0pt; font-family: arial,sans-serif; font-size: x-small;">Mean temperature<br>for the day.</p> is what your after with either strpos or preg_match ya can get the temp I prefer preg_match <?php $contents=file_get_contents('http://www.almanac.com/weatherhistory/oneday.php?number=725090&wban=14739&day=1&month=1&year=1946&searchtype=zip'); preg_match('@MEAN<br>TEMPERATURE.*?;">([\d\.]+)</b>@ms',$contents,$match); $mean=$match[1]; echo "Mean Temp: $mean<br>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/91430-quick-way-to-get-this-data/#findComment-468566 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.