国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Linux > 正文

改進后的《自動顯示天氣預報》小程序(Linux和Windows環境都可以)

2024-08-28 00:23:35
字體:
來源:轉載
供稿:網友

這次改進,主要是增加了圖象的獲取,并提供了一個比較完整的獲取遠端文件的函數。具體代碼如下:
<?
$fcont=file("http://www.bjmb.gov.cn/today.asp");
$arr=array();
for($i=0;$i<count($fcont);$i++){
    $tmp=$fcont[$i];
    $tmp=ereg_replace("<br>"," ",$tmp);
    if(!strstr(strtolower($tmp),"img")){
        $tmp=trim(strip_tags($tmp));
    } else {
        $st=ereg_replace("><",">⌒<",$tmp);
        $stt=split("⌒",$st);
        foreach($stt as $key => $value){
            if(strstr($value,"img") ){
                $tmp=$value;
                if(strstr($tmp,"bt9.jpg") || strstr($tmp,"colline.gif")){
                    $tmp="";
                }else{
                    $tmp=ereg_replace("/"","",$tmp);
                    $st=split("src=",$tmp);
                    $st1=split(" ",$st[1]);getpic("http://www.bjmb.gov.cn/$st1[0]","image");
                    if(count($st)>2){
                    $st2=split(" ",$st[2]);getpic("http://www.bjmb.gov.cn/$st1[0]","image");
                    }
                    $tmp=ereg_replace("src=","width=30 height=30 align=absmiddle src=",$tmp);
                }
            }
        }
    }
    if(trim($tmp)!="" && trim($tmp)!=" ") $arr[]=$tmp;
}
$yb=array();
for($i=2;$i<count($arr)-6;$i++){
    $yb[]=$arr[$i];
}
?>
<br>
<script language="javascript">
<!--
syb="";
<?
$exp="-3-7-9-14-18-20-25-";
for ($i=1;$i<count($yb);$i++){
    if (!strstr($exp,"-".(string)($i+1)."-")){
?>
    syb=syb+'<?=$yb[$i];?> ';
<?}}?>
document.write("<?=$yb[0]?>"+":");
document.write("<marquee width=400 align=middle scrollamount=5 scrolldelay=200>"+syb+"預報</marquee>");
//-->
</script>
<?
function getpic($url,$dir){
    $tmp=split("/",$url);
    $fname=$tmp[count($tmp)-1];
    if(strstr($dir,"//")){
        if(substr($dir,-2)=="//") $file=$dir.$fname;else $file=$dir."//".$fname;
    }else{        
        if(substr($dir,"/")){
            if(substr($dir,-1)=="/") $file=$dir.$fname;else $file=$dir."/".$fname;
        }
        else{
            return ;
        }
    }
    if(!(file_exists("$dir") && is_dir("$dir"))) mkdir($dir,0777);
    if(file_exists($file)) return ;
    $fpo=fopen($file,"wb");
    if(!$fpo) return ;
    $num=0;
    do{
        $num++;
        $fpi=fopen($url,"r");
    }while(!$fpi && $num<3);
    if(!fpi)    return ;
    while(!feof($fpi)){
        $cont=fread($fpi,128);
        fwrite($fpo,$cont,128);
    }
    fclose($fpi);
    fclose($fpo);
}
?>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 白山市| 高邮市| 重庆市| 扶余县| 湄潭县| 兴业县| 南充市| 库伦旗| 始兴县| 城市| 镇江市| 图木舒克市| 即墨市| 庆云县| 娄烦县| 大悟县| 桑植县| 漳浦县| 南皮县| 清镇市| 镇巴县| 临海市| 商都县| 新建县| 昌平区| 楚雄市| 黔东| 宁化县| 邛崃市| 东乡| 长乐市| 北碚区| 门源| 平泉县| 克什克腾旗| 尚义县| 沈阳市| 德安县| 安新县| 赤峰市| 同江市|