PHP天气预报小偷08年版_PHP

WBOY
Release: 2016-06-01 12:25:12
Original
925 people have browsed it

/************************************************************************
名称:天气预报小偷
功能:每天读取新浪网上的天气情况并保存到本地,然后再从本地读取显示
开发:n3tl04d QQ:10492315 1妹儿:n3tl04d[at]gmail.com [url]http://smboy.bokee.com[/url]
更新日期:2007年11月22日
*************************************************************************/
@header("Content-Type:text/html;charset=gb2312");
 error_reporting(0);

/*******************看weather.txt的修改时间是否为当天,如果是昨天的就要上网抓结果***********/
     $tmp = filemtime("weather.txt");
    $tt1=date("Ymd",$tmp)."
";
    $tt2=date("Ymd");
    if ($tt1    //echo "要抓结果";
    unlink("weather.txt");
    $url = "http://php.weather.sina.com.cn/search.php?city=广州" ;
    $content = file_get_contents($url);
    preg_match_all('/

(.+?)/si',$content,$result);
    for($i=0;$i        $x= strip_tags($result[1][$i])."\n";
        $handle = fopen ("weather.txt", "a");
            fwrite($handle, $x);
         fclose($handle);

      }
      listweather();
  
    } else {
        // echo "直接从weather.txt读结果";   
        listweather();
    }

    //天气显示函数
    function listweather() {
    $filename="weather.txt";
    $handle=fopen($filename,"r");

    if ($handle) {   
        $contents=fread($handle,filesize($filename));
        fclose($handle);
        $cc=explode("\n",$contents);
        $today=explode(" ",$cc[0]);
        $tomo=explode(" ",$cc[1]);
?>


 
   

     
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!