求php抓取网站天气代码

解决方案 »

  1.   

    基本上都有接口的,新浪的,腾讯的等等
    http://www.weather.com.cn/data/sk/101110101.html
    http://m.weather.com.cn/data/101110101.html
    等等
    其中101110101是城市的代码,获得城市代码进入weather.com.cn
      

  2.   

    貌似几乎所有的这类工具都是这么抓的,voteon83 我一般也不告诉你..哈哈哈
      

  3.   


    因为需要有自己的外观,那都是json格式的数据,用起来也很方便,何乐而不为呢?
      

  4.   

    http://6shandong.com/123/weatherplugin.html
      

  5.   

    $source = file_get_contents("http://www.weather.com.cn/data/cityinfo/".$carr[1].".html");
    $obj=json_decode($source);
    echo $obj->weatherinfo->city.' '.$obj->weatherinfo->weather.' '.$obj->weatherinfo->temp1.'~'.$obj->weatherinfo->temp2;