I've looked around for some examples on how to add a quick 5 day overview forecast to your own site, but am coming up empty. I figured some of the weather sites would offer this.

Is there another way like through screen scraping or maybe a PHP/XML type solution?

Anyone else done this?

    I've seen some good 5 day weather forecasts in Yahoo...

    why don't you make a frame in your page to show them directly from their source location?

      Originally posted by altexis
      I've seen some good 5 day weather forecasts in Yahoo...

      why don't you make a frame in your page to show them directly from their source location?

      That seems kind of messy though. I was just hoping to include a graphic or maybe a table within a page. Of course, give credit where it's due.

        I remember seeing a gov site that had just about every city listed with current weather. I think they also had forecasts, but I'm not sure. I know the data was free to use.

        Look around for gov weather site.

          You could also use an iframe tag which is still a frame but it can be small and not messy at all...

          have a look at this
          http://www.phpbuilder.com/board/showthread.php?s=&threadid=10223920

          if you're not looking for a link... then how else could you take the picture?
          you could only use a static image from another site (which is maybe updated once a day or so..) but this would take a lot of search around the internet and much luck

            We screen-scrape from the National Weather Service site (U.S.), www.weather.gov. You also can get aviation forecasts in METAR and TAF format, which require some translation. There are plenty of PHP modules for current conditions -- google "php weather" for info.

              Found that php weather app but it never returned any data for the cities I tried.

              I thought I remembered weather.com returning a dynamic graphic that you could link to with their approval but I guess they've gotten away from that.

              It'd be nice to have something simple like current temp then a quick graphic of the 5 day forecast. I don't need wind speeds and all that other stuff.

              Is there an XML service for this? And if anyone knows of a graphic we could link to, even if it's only updated once a day or something, that's fine.

              Worse comes to worse, we'll just have to LINK to the current weather for the area 🙁

                You can read directly from a site, I choose yahoo weather for this script i put together

                give this a shot

                function getWeather(){
                global $myFile, $myLine;
                if(!($myFile=fopen("http://weather.yahoo.com/forecast/CAXX0518_c.html?force_units=1","r")))
                {
                echo "The Weather interface is down for maintenance.";
                exit;
                }
                while(!feof($myFile))
                {
                // Read each line and add to $myLine
                $myLine.=fgets($myFile,255);
                }
                fclose($myFile);
                // Extract everything between start and end. You need to include these lines
                //in the headlines or pick some unique substring in the html to mark the start
                //and end of the weather news.
                $start="<!-- CURCON-->";
                $end="<!-- END CURCON-->";
                $start_position=strpos($myLine, $start);
                $end_position=strpos($myLine, $end)+strlen($end);
                $length=$end_position-$start_position;

                $myLine=substr($myLine, $start_position, $length);

                echo $myLine;
                }

                  Download NuSOAP from nusoap.com and search for Web Services PHP on google.. there was a SOAP server run by a company that serves off weather data in a WSDL file.. you can write a small SOAP application to return the data to your php script and parse it from there..

                    Originally posted by sdizier
                    You can read directly from a site, I choose yahoo weather for this script i put together

                    give this a shot

                    I get a blank page with this code.

                      make sure you call the funtion somwhere.

                      you can change the echo $myLine; to return $myLine; if you like and where you want the weather to show you would simply put
                      <?echo getWeather();?>

                      This function does not need anyother formating the only thing you'll want to change is $myFile variable at the top to point to the weather page of your choice.

                      mine is pointing to vancouver local weather. if you are still going to point at yahoo weather then you don't need to change anything else other then, perhaps the $start and $end to varsiables. just look at the weather page of your choice and look for a starting and ending point between the weather section of the html. yahoo uses the <!-- CURCON--> and <!-- END CURCON--> html comments to strat the weather block.

                      other wise thats it.

                      good luck
                      Slan

                        There we go, thanks for the quick reply!

                          Hahah what the hell is up with Yahoo html source code for that page:

                          http://weather.yahoo.com/forecast/CAXX0518_c.html?force_units=1

                          <b> 
                          whazzap?
                          --&ordm;&nbsp;</b></font>--></td>
                          <td rowspan=2 bgcolor=#ffffff>
                          <!-- teswt 
                          <img 
                          src="http://us.i1.yimg.com/us.yimg.com/i/us/we/52/223.gif"
                           width=52 height=52 alt="" border=0>
                          <br><font
                           face=Arial 
                          size=2>
                          sucks out there
                          </font>
                          teswt -->
                          </td>
                          <td bgcolor=ffffff><!-- <font face=Arial size=3>Hi:&nbsp;<b>6</b>
                          -- yo yo --
                          </font>--></td>
                          </tr><tr align=center><td bgcolor=ffffff><!-- <font face=Arial size=3>
                          Lo:&nbsp;<b>-- testing --1--
                          </b></font>
                          --></td>
                          </tr>
                          </table></td>
                          </tr></table>
                          <table cellpadding=0 cellspacing=0 border=0 width="90%" bgcolor=#666666><tr><td>
                          <table border=0 cellpadding=3 cellspacing=1 width="100%" bgcolor=#666666><tr align=center>
                          <td rowspan=2 bgcolor=66ccff><font face=Arial size=2>Currently:</font><br><font size="5"
                           face=Arial>
                          <b> 
                          <!-- 22 isn't 
                          yahoo a great 
                          company to work for? -->
                          0<!-- 
                          test
                          asdf 
                          -->&ordm;&nbsp;</b></font></td>
                            

                          Notice the comments. 😕 :eek:

                            😃 yes i noticed that myself (the comments that is) ha ha
                            slan

                              I'm actually trying to do the 5 Day forecast, which works fine, but for some reason, it won't show the link in the 6-10 day table cell. I'm guessing because it doesn't like the quotes in that line or something?

                              <br><table cellpadding=0 cellspacing=0 width=100%><tr><td></td><td align=center valign=top><font face=Arial size=2><b>
                              <a href="http://rd.yahoo.com/M=216468.1953735.3440073.1888545/D=wt/S=20078731:WTHE/A=1056905/R=0/*[url]http://www.weather.com/weather/extended/USKS0637?par=yahoo&site=www.yahoo.com&promo=forecast[/url]">Extended Forecast at weather.com</a></b></font></td><td><br><br></td></tr></table>
                              </td>
                              

                              Is there any way to get this script to allow that or parse the quotes?

                                hmmm, it appears that the html code you sent me in your last post is broken there is a missing > bracket in the first url

                                Slan

                                  Originally posted by sdizier
                                  hmmm, it appears that the html code you sent me in your last post is broken there is a missing > bracket in the first url

                                  Slan

                                  I think it's the forum doing that, here's the actual line of code:

                                  <a href="http://rd.yahoo.com/M=216468.1953735.3440073.1888545/D=wt/S=20078731:WTHE/A=1056905/R=0/*http://www.weather.com/weather/extended/USKS0637?par=yahoo&site=www.yahoo.com&promo=forecast">Extended Forecast at weather.com</a></b></font></td><td><br><br></td></tr></table>

                                  Sorry about that.

                                    Write a Reply...