inicio mail me! sindicaci;ón

Write program of a weather forecast with ASP XMLHTTP

Oneself assume office at website of portal of a this locality, everyday the weather on the website must be updated. As time passes feels quite troublesome, wrote a time news thief then, post come out everybody consults the system asks: Support FSO, TCP/IP of server UDP   does not have screen.

The content of thief is below:

FileName TianQi.asp

Write By Niaoked QQ408611119

Www.knowsky.com

< %

30 Then of < of If Hour(now)=9 And Minute(now)

GetCategories()

End If

Function GetCategories()

On Error Resume Next

Dim OXMLHTTP ‘ As Object

Dim OCategories ‘ As Object

Dim BodyText

Dim Pos, pos1

Set OXMLHTTP = CreateObject(”Microsoft.XMLHTTP” )

‘—Set The XMLHTTP Call And Issue Send (no Parm As Category

‘—Is Included In URL

OXMLHTTP.open “GET” , OXMLHTTP.open “GET” ,, Http://weather.china.com.cn/travel_gntq.php? Cityid=56196&cityname= continous in relief ” , this place changes False ‘ yourself’s address

OXMLHTTP.send

‘—Load The Response Into The Categories Data Island

BodyText=oXMLHTTP.responsebody

BodyText=BytesToBstr(BodyText, “Gb2312″ )

Pos=Instr(BodyText, “< Body” )

Pos1=Instr(BodyText, “< / Body > ” )

BodyText=mid(BodyText, pos, pos1)

BodyText=split(BodyText, “< Table” )

Pos=Instr(BodyText(4) , “< Tr” )

Pos1=Instr(BodyText(4) , “< / Tr > ” )

Body=mid(BodyText(4) , pos, len(BodyText(4))-pos)

Body=split(body, “< / Table > ” )

Body1=split(replace(replace(replace(body(0) , “” of < Br > , “”) , “< / Td > ” , “”) , “< / Tr > ” , “”) , “Weather ” )

For I= 1 To Ubound(body1)

Body3=split(body1(i) , “< Td” )

Weather=weather&”Document.write(”" “&I&"$ "&”Weather “&HTMLEncode(trim(body3(0)) )&&Vbcrlf

Next

Weather=replace(weather, “1$” , “> of < FONT Color=#ffffff [today] < / FONT > ” )

Weather=replace(weather, “2$” , “> of < FONT Color=#ffffff [tomorrow] < / FONT > ” )

Weather=replace(weather, “3$” , “> of < FONT Color=#ffffff [acquired] < / FONT > ” )

Set Fs = CreateObject(”Scripting.FileSystemObject” )

Set F = Fs.CreateTextFile(request.ServerVariables(”APPL_PHYSICAL_PATH” )&”Tq.js” , true)

F.write(”document.write(’ continous Yang Tian enrages forecast: ‘) ;" &vbcrlf&Replace(weather, “” of < BR > ,

F.close

Set F = Nothing

Set Fs = Nothing

Yang Tian of Response.write ” continous enrages forecast:” &Weather

Set OXMLHTTP = Nothing

0 Then of > of If Err.number <

Response.write ” made mistake, the mistake describes: "&err.description&”Wrong origin of < Br > “&Err.source

Response.End()

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 HTMLEncode(fString)

If Not IsNull(fString) Then

FString = Replace(fString, “> ” , ">" )

FString = Replace(fString, “< ” , "<" )

FString = Replace(fString, CHR(32) , "") ‘

FString = Replace(fString, CHR(9) , "") ‘

FString = Replace(fString, CHR(34) , """ )

FString = Replace(fString, CHR(39) , "'") ‘ only quote filters

FString = Replace(fString, CHR(13) , CHR(13) ,,

FString = Replace(fString, CHR(10)&CHR(10) , “< / ” of > of P of P > < )

FString = Replace(fString, CHR(10) , “” of < BR > )

HTMLEncode = FString

End If

End Function

% >

Bookmark:Digg Del.icio.us Reddit

Leave a Comment