色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

利用中國(guó)天氣預(yù)報(bào)接口實(shí)現(xiàn)簡(jiǎn)單天氣預(yù)報(bào)

復(fù)制代碼 代碼如下:
<?php
header("content-type:text/html;charset=utf-8");
$weather = file_get_contents("http://www.weather.com.cn/data/sk/101280601.html");
echo $weather;
?>

復(fù)制代碼 代碼如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gbk" />
<style type="text/css">
.all span {font:bold 30px/50px "宋體";color:red;}
</style>
<title>天氣預(yù)報(bào)</title>
</head>
<body>
<div class="all">
這里是:<span class="place">城市</span>,
氣溫是<span class="temp">氣溫</span>,
風(fēng)向:<span class="wind">風(fēng)向</span>,
風(fēng)力:<span class="windPower">風(fēng)力</span>
</div>
<script type="text/Javascript" src="http://127.0.0.1/jquery.js"></script>
<script type="text/Javascript">
$(function () {
$.ajax({
//請(qǐng)求的地址
url : "http://127.0.0.1/weather.php",
//請(qǐng)求成功后執(zhí)行的函數(shù)
success : function (data) {
//用eval()解析返回來(lái)的數(shù)據(jù),將字符串轉(zhuǎn)成JSON格式
var oD = eval('('+data+')');
//用jquery-1.8.2獲取元素
var $place = $(".place"),
$temp = $(".temp"),
$wind = $(".wind"),
$windPower = $(".windPower");
//將返回來(lái)的數(shù)據(jù)放到相應(yīng)的位置
$place.html(oD["weatherinfo"]["city"]);
$temp.html(oD["weatherinfo"]["temp"] + "°");
$wind.html(oD["weatherinfo"]["WD"]);
$windPower.html(oD["weatherinfo"]["WS"]);
}
});
})
</script>
</body>
</html>

php技術(shù)利用中國(guó)天氣預(yù)報(bào)接口實(shí)現(xiàn)簡(jiǎn)單天氣預(yù)報(bào),轉(zhuǎn)載需保留來(lái)源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 芜湖县| 大厂| 玛纳斯县| 壤塘县| 广元市| 乌拉特中旗| 洞头县| 明星| 天津市| 天气| 龙口市| 安阳县| 偃师市| 化隆| 峨眉山市| 汕头市| 贵德县| 高安市| 体育| 江华| 屯留县| 高唐县| 永兴县| 个旧市| 广汉市| 南昌县| 宜丰县| 曲阜市| 南宫市| 南木林县| 稻城县| 蓬莱市| 右玉县| 梁山县| 西畴县| 满城县| 佛冈县| 葵青区| 海兴县| 沽源县| 霍林郭勒市|