📄 weather.cgi
字号:
#!/usr/bin/perl
# 请修改下面图片目录设置(可别调用我的啊)
$imgurl="http://www.flyao.com/cgi-bin/weather/images/";
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday)= localtime(time+(3600*$time_hour));
$mon=$mon+1;
if($mon <10){$mon="0".$mon;}
if($mday<10){$mday="0".$mday;}
if($hour<10){$hour="0".$hour;}
if($min<10){$min="0".$min;}
if($sec<10){$sec="0".$sec;}
$year=$year+1900;
$real_time="$year$mon$mday";
$date="$year年$mon月$mday日";
$jsfile="/usr/home/uk21g1/htdocs/weather/$real_time.js";
# 下面这一项请填写你的绝对路径。(如果是win系统的话,其它的系统直接填文件名)
require "E:/flyao/cgi-bin/weather/gethtml.cgi";
print "Content-type: text/html\n\n";
$dispcity=$ENV{'QUERY_STRING'};
$city_china=&gethtml('http://www.cctv.com/weather/city_china.js');
$pollution=&gethtml('http://www.cctv.com/weather/pollution.js');
$pollution=~s/\n//g;
@pcitylist=split(';',$pollution);
foreach(@pcitylist) {
if (($_ !~/Array/)&&($_ =~ /(\'(.*))/i)) {
$v=$1;
$v=~s/'//g;
$v=~s/\)/,/g;
$v=~s/,,/,/g;
push(@pdata,$v);
}
}
$city_china=~s/\n//g;
@citylist=split('=new today_',$city_china);
foreach(@citylist) {
if (($_ !~/中央气象台城市天气预报/)&&($_ =~ /(\'(.*));/i)) {
$v=$1;
$v=~s/'//g;
$v=~s/\)/,/g;
$v=~s/,,/,/g;
push(@data,$v);
}
}
# 下面这一项请填写你的绝对路径。(如果是win系统的话,其它的系统直接填文件名)
open(TMP,"E:/flyao/cgi-bin/weather/weather.txt");
@weather=<TMP>;
close(TMP);
print <<EOF;
<marquee scrollamount=1 scrolldelay=60 width=100% height=15 onmouseover='this.stop()' onmouseout='this.start()'>
EOF
$outstrs='';
foreach(@data) {
($city,$x,$y,$wer,$wu,$wd,$fx)=split(',',$_);
($id,$cweather,$imgname)=split(',',$weather[$wer-1]);
$kq='';
$wr='';
foreach(@pdata) {
($city1,$kq1,$wr1)=split(',',$_);
if($city1 eq $city) { $kq=$kq1; $wr=$wr1; }
}
$imgname=~s/images\///isg;
if($wr eq "") {$wr="无"; }
if($city eq "北京") {
unless(-f "$jsfile") {
open(js,">$jsfile");
print js "$date北京市天气预报:$cweather,最高温度$wu,最低温度$wd,空气质量$kq,首要污染物为$wr。";
close(js);
}
}
print <<EOF;
<span style="font size:9pt"> $city:<img src=\"$imgurl$imgname\" width=17 height=17>$cweather
EOF
}
print <<EOF;
<marquee>
EOF
exit;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -