|
发表于 2005-6-11 20:15:44
|
显示全部楼层
$fcont = @file_get_contents("http://www.tq121.com.cn/forecast/cf.php");
$date = explode("<font color=\"#FF0000\">", $fcont);
$fdate = substr($date[1],2,18);
$city = explode("461,292,498,308", $fcont);
$fcast = $city[1];
$fcastarr = explode("<br>",$fcast);
$weather["天气"] = substr(trim($fcastarr[1]),5);
$weather["温度"] = substr(trim($fcastarr[2]),5);
$weather["风向"] = substr(trim($fcastarr[3]),5);
$weather["风力"] = substr(trim($fcastarr[4]),5);
//print_r($weather);
$pic = "sunny.jpg";
if (strstr($weather["天气"],"晴"))
$pic = "sunny.jpg";
elseif (strstr($weather["天气"],"多云"))
$pic = "cloudy.jpg";
elseif (strstr($weather["天气"],"雾"))
$pic = "foggy.jpg";
elseif (strstr($weather["天气"],"雹"))
$pic = "frezz.jpg";
elseif (strstr($weather["天气"],"雨"))
$pic = "rain.jpg";
elseif (strstr($weather["天气"],"雪"))
$pic = "snow.jpg";
elseif (strstr($weather["天气"],"雨加雪"))
$pic = "mixed.jpg";
elseif (substr($weather["风力"],1) >= 5)
$pic = "windy.jpg";
?>
<body style="text-align:center;font-size:14px;font-family:Arial">
上海-<span style="color:red"><? echo $fdate; ?></span>发布的最新天气预报:<br><br>
<img src="images/<? echo $pic; ?>">
<br>
<br>
<? echo $weather["天气"]; ?>,<? echo $weather["温度"]; ?>,风力:<? echo $weather["风力"]; ?>,风向:<? echo $weather["风向"]; ?> |
|