<!--#include file="../../p_inc/config.asp"-->
<!--#include file="Function.asp"-->
<%

response.Buffer=true
response.contenttype="text/html;charset=gb2312"
Server.ScriptTimeOut=9999999
on error resume next
response.Flush()

response.Flush()
Dim G_XMLHTTP:G_XMLHTTP="MSXML2.XMLHTTP"
Dim Temp_G_Stream_2:Temp_G_Stream_2="stream"
Dim G_Stream:G_Stream="adodb."&Temp_G_Stream_2
Const G_FSO = "Scripting.FileSystemObject"
Dim qingtian_str,flag,id_c,id_a2,id_a,id_template,ka
flag=true
Set N_Fso=New Class_QingTian_FSO



'====获取城市id=====
Function GetCityId()
	Dim id_a,id_a2,ocity,v,RequestId
	RequestId=N_Fso.Bint(Trim(Request("wid")))
	v="hao123.com"
	IF RequestId=0 Then
		IF v="hao123.com" Then
			id_a=N_Fso.bytesToStr(N_Fso.getRemoteContent("http://search.hao123.com/weather/bin/forecast.php","body"),"gb2312")
			id_a2=N_Fso.GetContent(id_a,"/weather\/",".shtml""",0)
			RequestId=N_Fso.Bint(id_a2)	
		ElseIF v="360.cn" Then	 
			
		End IF	
	End IF
	GetCityId=RequestId	
End Function


id=0
ka=Request("a")
oprovince=""
ocity=""
id_template="weather.html"
IF ka="1" Then
	id_template="weather.html" 'skin1样式的
ElseIF ka="4" Then
	id_template="weather4.html" 'skin9样式的	
ElseIF ka="2" Then
	id_template="template/"&G_moban&"/"&G_moban_html&"/weathers.html" '自定义样式的
	id_template=N_Fso.Add_Root_Dir("/template/"&G_moban&"/"&G_moban_html&"/weathers.html")
ElseIF ka="3" Then
	id_template="weather3.html" '中国天气网通用样式
ElseIF ka="0y" Then '原始的
	oprovince=Trim(Request("province"))
	ocity=N_Fso.Bint(Trim(Request("city")))
	IF ocity="0" Then
		ocity=GetCityId()
	End IF	
	oqingtian_str=N_Fso.bytesToStr(N_Fso.getRemoteContent("http://m.weather.com.cn/data/"&ocity&".html","body"),"UTF-8")
	Response.Write oqingtian_str
	Response.End()
Else
	id_template="weather3.html" '中国天气网通用样式
End IF

id=N_Fso.Bint(Request("wid"))

IF id=0 Then id="101010100"
t_saveurl=N_Fso.Add_Root_Dir(G_BIG_T&"/"&G_moban&"/"&"qingtiandy_cn/"&id&"/w.html")
t_flag=N_Fso.IsExistIndexPage(1,t_saveurl)
TWhere="北京"
T1="阵雨转雷阵雨":T2="26℃～ 23℃":T3="http://www.weather.com.cn/":T4="img/5.png"
M1="阵雨":M2="26℃～22℃":M3="http://www.weather.com.cn/":M4="img/4.png"
H1="多云":H2="32℃～25℃":H3="http://www.weather.com.cn/":M4="img/2.png"

IF not t_flag Then
	FileStr=N_Fso.Qingtiandy_getfilecontent(id_template) '获取全部文本
	qingtian_str=N_Fso.bytesToStr(N_Fso.getRemoteContent("http://m.weather.com.cn/data/"&id&".html","body"),"UTF-8")
	IF Instr(qingtian_str,"Not Found")=0 ANd qingtian_str<>"" Then
		TWhere=N_Fso.GetContent(qingtian_str,"""city"":""","""",0) '城市
		T1=N_Fso.GetContent(qingtian_str,"""weather1"":""","""",0) '今天天气
		T2=N_Fso.GetContent(qingtian_str,"""temp1"":""","""",0) '今天温度
		T3="http://www.weather.com.cn/html/weather/"&id&".shtml"
		T4="img/"&N_Fso.GetContent(qingtian_str,"""img1"":""","""",0)&".png" '今天天气图标
		T5=N_Fso.GetContent(qingtian_str,"""img1"":""","""",0) '今日天气图标数字
		
		M1=N_Fso.GetContent(qingtian_str,"""weather2"":""","""",0)
		M2=N_Fso.GetContent(qingtian_str,"""temp2"":""","""",0)
		M3="http://www.weather.com.cn/html/weather/"&id&".shtml"
		M4="img/"&N_Fso.GetContent(qingtian_str,"""img2"":""","""",0)&".png"
		M5=N_Fso.GetContent(qingtian_str,"""img2"":""","""",0)
		
		H1=N_Fso.GetContent(qingtian_str,"""weather3"":""","""",0)
		H2=N_Fso.GetContent(qingtian_str,"""temp3"":""","""",0)
		H3="http://www.weather.com.cn/html/weather/"&id&".shtml"
		H4="img/"&N_Fso.GetContent(qingtian_str,"""img3"":""","""",0)&".png"
		H5=N_Fso.GetContent(qingtian_str,"""img3"":""","""",0)
				
		FileStr=Replace(FileStr,"{$TWhere}",TWhere)
		FileStr=Replace(FileStr,"{$T1}",T1)
		FileStr=Replace(FileStr,"{$T2}",T2)
		FileStr=Replace(FileStr,"{$T3}",T3)
		FileStr=Replace(FileStr,"{$T4}",T4)	
		FileStr=Replace(FileStr,"{$T5}",T5)
		
		FileStr=Replace(FileStr,"{$M1}",M1)
		FileStr=Replace(FileStr,"{$M2}",M2)
		FileStr=Replace(FileStr,"{$M3}",M3)
		FileStr=Replace(FileStr,"{$M4}",M4)	
		FileStr=Replace(FileStr,"{$M5}",M5)
		
		FileStr=Replace(FileStr,"{$H1}",H1)
		FileStr=Replace(FileStr,"{$H2}",H2)
		FileStr=Replace(FileStr,"{$H3}",H3)
		FileStr=Replace(FileStr,"{$H4}",H4)	
		FileStr=Replace(FileStr,"{$H5}",H5)	
		
		FileStr=Replace(FileStr,"{$a}",ka)
		FileStr=Replace(FileStr,"{$province}",oprovince)
		FileStr=Replace(FileStr,"{$city}",ocity)
		'**********************写入文件*****************************
		N_Fso.CreateFolderFile t_saveurl,FileStr
		
		Response.Write FileStr
	Else
		Response.Write N_Fso.Qingtiandy_getfilecontent(t_saveurl)
	End IF
Else
	Response.Write N_Fso.Qingtiandy_getfilecontent(t_saveurl)
End IF


%>


