日期:2013-12-06  浏览次数:20495 次

这次改进,主要是增加了图象的获取,并提供了一个比较完整的获取远端文件的函数。具体代码如下:
<?
$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];