<?php
$handle = fopen ("http://weather.cn.yahoo.com/weather.html?city=%E5%8C%97%E4%BA%AC", "rb");
$contents = "";
while (!feof($handle)) {
  $contents = fread($handle, 1024);
  $contents = trim($contents);
  if($contents="<!--{{start:今日 -->") {
  $start=true;
  echo "ok";
  }
  if($start==true){
  $today.=$contents;
  }
  if($contents=="<!--{{start:明日 -->"){
  $start=false;
}
}
fclose($handle);
?> 

解决方案 »

  1.   

    可能问题出在编码上,yahoo 的网页编码是 UTF-8的!
      

  2.   

    <?php
    $handle   =   fopen   ("http://weather.cn.yahoo.com/weather.html?city=%E5%8C%97%E4%BA%AC",   "rb");
    $contents   =   "";
    while   (!feof($handle))   {
        $contents   =   fread($handle,   1024);
        $contents   =   trim($contents);
        if($contents=" <!--{{start:今日   --> ")   { (这里应该是$contents==" <!--{{start:今日   --> ")
        $start=true;
        echo   "ok";
        }
        if($start==true){
        $today.=$contents;
        }
        if($contents==" <!--{{start:明日   --> "){
        $start=false;
    }
    }
    fclose($handle);
    ?>   
      

  3.   

    $contents==" <!--{{start:今日   --> "