weather.php
来自「PHP的天气预报小偷 PHP的天气预报小偷」· PHP 代码 · 共 47 行
PHP
47 行
<?php
/**
* @file weather.php <天气预报小偷>
*
* @author Rainman <zhang.yanan@trs.com.cn>
* @version $Id 2004-9-10 $
* @site http://www.wofeila.com
*/
$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("400,182,425,197", $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["风向"]; ?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?