Home >php教程 >php手册 >改进后的《自动显示天气预报》小程序(Linux和Windows环境都可以)-PHP应用-PHP教程-

改进后的《自动显示天气预报》小程序(Linux和Windows环境都可以)-PHP应用-PHP教程-

WBOY
WBOYOriginal
2016-06-13 10:02:391507browse

这次改进,主要是增加了图象的获取,并提供了一个比较完整的获取远端文件的函数。具体代码如下:

$fcont=file("http://www.bjmb.gov.cn/today.asp");
$arr=array();
for($i=0;$i    $tmp=$fcont[$i];
    $tmp=ereg_replace("
"," ",$tmp);
    if(!strstr(strtolower($tmp),"img")){
        $tmp=trim(strip_tags($tmp));
    } else {
        $st=ereg_replace(">⌒        $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");
          }

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn