<%'*****************************************" />

亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

免費天氣插件asp版本

系統(tǒng) 2022 0

天氣信息來源:中國天氣網(wǎng)【weather.com.cn】
根據(jù)QQ[http://fw.qq.com:80/ipaddress]得到ip地址和所在城市信息,
然后調(diào)用weather.com.cn網(wǎng)站的xml得到城市代碼,就可以得到JSON格式的天氣信息
setWeather函數(shù)可以自行修改生成您想要的天氣信息格式

效果如下:
免費天氣插件asp版本

Weather.asp
    
<%codepage=936%>
<%
'***********************************************************
' 文件名: 免費天氣插件asp版本,僅適用于中國用戶
' 版本:  mmWeather1.0 
' 作者:  走過四季 
' 電子郵件: maomaoysq@sohu.com 
' 日期:  2010年01月14日
' 功能: 根據(jù)用戶的ip地址自動獲取所在城市的天氣信息
' 聲明:   
'   本代碼可以自由使用,但請保留此版權(quán)聲明信息 
'   如果您對本代碼進行修改增強, 
'   請發(fā)送一份給俺。 
'**********************************************************

dim cityid,city1,city2,tmpHtml,tmpArr,tLevel,weaXML,weaHTML
tLevel = 0
weaXML = "http://service.weather.com.cn/plugin/"
weaHTML = "http://m.weather.com.cn/data/"
cityid = Trim(Request.Cookies("wea_cityid"))

if cityid = "" then
	tmpHtml = GetUrlBody("http://fw.qq.com:80/ipaddress","gb2312")
	tmpHtml = BytesToBstr(tmpHtml,"gb2312")
	if tmpHtml = "" then
		Response.Write("Error:Can't get ip address from qq.com.")
	end if
	tmpArr = Split(tmpHtml,",")
	Response.Cookies("wea_cityip") = tmpArr(0)
	city1 = tmpArr(2)
	city2 = tmpArr(3)
	city1 = Replace(city1,"省","")
	city1 = Replace(city1,"市","")
	city1 = Replace(city1,"""","")
	city2 = Replace(city2,");","")

	if Trim(city2) = "" then
		city2 = city1
	else
		city2 = Replace(city2,"市","")
		city2 = Replace(city2,"自治區(qū)","")
	end if
	city2 = Replace(city2,"""","")
	'call getCityCode(city2)
	if cityid = "" then
		call getLocalCity("data/city.xml",0)
	end if
else
	call getWeather(cityid)
end if

function getLocalCity(ByVal tUrl,ByVal tLevel)
	dim iPos,iPos1,cid,cArr
	tmpHtml = GetUrlBody(weaXML & tUrl,"")
	
	iPos = InStr(tmpHtml,city1)
	iPos1 = InStr(tmpHtml,city2)
	if tLevel<3 then
		if iPos>0 then
			tmpHtml = Left(tmpHtml,iPos-1)
			iPos = InStrRev(tmpHtml,",")
			tmpHtml = Right(tmpHtml,len(tmpHtml)-iPos)
			cid = Replace(tmpHtml,"|",""):
		elseif iPos1>0 then
			tmpHtml = Left(tmpHtml,iPos1-1)
			iPos = InStrRev(tmpHtml,",")
			tmpHtml = Right(tmpHtml,len(tmpHtml)-iPos)
			cid = Replace(tmpHtml,"|",""):
		end if
		call getLocalCity("data/city" & cid & ".xml",tLevel+1)
	else
		cid = Split(tmpHtml,"|")(1)
		call getWeather(cid)
	end if
end function

function getWeather(ByVal cid)
	Response.Cookies("wea_cityid") = cid
	tmpHtml = GetUrlBody(weaHTML & cid & ".html","")
	if tmpHtml="" then
		Response.Write("Error:Nothing is from "&weaHTML & cid & ".html")
	else
		Response.Write("<script language=javascript>"& vbCrLf &"function window.onload(){var oJson = "& tmpHtml & vbCrLf)
		Response.Write("setWeather(oJson);}"& vbCrLf &"</script>")
	end if
end function

Function BytesToBstr(body,Cset)
	dim objstream
	set objstream = Server.CreateObject("adodb.stream")
	objstream.Type = 1
	objstream.Mode =3
	objstream.Open
	objstream.Write body
	objstream.Position = 0
	objstream.Type = 2
	objstream.Charset = Cset
	BytesToBstr = objstream.ReadText
	objstream.Close
	set objstream = nothing
End Function 

Public Function GetUrlBody(ByVal URL,ByVal CharSet)
	On Error Resume Next
	Set Http = Server.CreateObject("MICROSOFT.XMLHTTP")
	Http.Open "GET", URL, False
	Http.Send
	If Http.Readystate = 4 Then
		If Http.Status = 200 Then
			if CharSet="gb2312" then
			GetUrlBody = Http.responseBody
			else
			GetUrlBody = Http.responseText
			end if
		End If
	End If
End Function

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>中國天氣網(wǎng)-天氣預(yù)報</title>
</head>
<body>
<div class="Weather">
	<span id="city"></span>&nbsp;<span id="temp1"></span>&nbsp;<span id="wd1"></span>
</div>
</body>
</html>
<script language=javascript>
function setWeather(objJson)
{
	var imgHtml = "";
	var cityname = objJson.weatherinfo.city;		//上海
	var id = objJson.weatherinfo.cityid;			//101020100 
	var cityinfo1 = objJson.weatherinfo.weather1;	//晴轉(zhuǎn)多云
	var wd1 = objJson.weatherinfo.wind1;			//北風(fēng)3-4級
	var fl1 = objJson.weatherinfo.fl1;			//3-4級
	var temp1 = objJson.weatherinfo.temp1;		//4℃~-1℃

	//注釋里面為更詳細(xì)的信息,您可以根據(jù)自己需要使用
	/*var cityinfo2=objJson.weatherinfo.weather2;
	var wd2=objJson.weatherinfo.wind2;
	var fl2=objJson.weatherinfo.fl2;
	var temp2=objJson.weatherinfo.temp2;
	var img1=objJson.weatherinfo.img1;
	var img2=objJson.weatherinfo.img2;
	var img3=objJson.weatherinfo.img3;
	var img4=objJson.weatherinfo.img4;
	var index=objJson.weatherinfo.index;
	var index_d=objJson.weatherinfo.index_d;
	var index_xc=objJson.weatherinfo.index_xc;
	var index_uv=objJson.weatherinfo.index_uv;
	var date=objJson.weatherinfo.date;
	var date_y=objJson.weatherinfo.date_y;
	var imgtitle1=objJson.weatherinfo.img_title1;
	var imgtitle2=objJson.weatherinfo.img_title2;
	var imgsingle=objJson.weatherinfo.img_single;
	var imgtitlesingle=objJson.weatherinfo.img_title_single;
	*/

	document.all.city.innerHTML = cityname
	document.all.temp1.innerHTML = cityinfo1
	document.all.wd1.innerHTML = wd1 + fl1
}
</script>

  

免費天氣插件asp版本


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 九九性视频 | 亚洲国产伦理 | 国产亚洲欧洲 | 色偷偷亚洲第一成人综合网址 | 成人日韩 | 午夜香蕉网 | 日日日日人人人夜夜夜2017 | 久久香蕉国产线看精品 | 久草国产在线 | 国内精品久久影院 | 4虎最新网站 | 日日夜夜精品免费视频 | 免费观看一区二区 | 国产成人久久久精品毛片 | 新久草在线 | 亚洲一级毛片免费观看 | 四虎永久免费在线 | 女人一级一级毛片 | 久久精品网址 | 亚洲性片 | 黄色免费网站在线观看 | 自拍偷自拍亚洲精品被多人伦好爽 | 在线视频一区二区日韩国产 | 午夜特级毛片 | 五月天婷婷免费观看视频在线 | 日本特级全黄一级毛片 | 特黄特黄一级高清免费大片 | 欧美理论片在线观看 | 97久久精品视频 | 国产极品嫩模在线观看91精品 | 婷婷四房色播 | 中文字幕一区二区三区视频在线 | 国产精品男人的天堂 | 日本免费毛片在线高清看 | 内衣办公室动漫久久影院 | 亚色视频在线观看 | 国产成人亚洲精品2020 | 亚洲精品色婷婷在线影院麻豆 | 欧美成人免费全部观看天天性色 | 欧美一级在线 | 国产精品久线观看视频 |