Capture webpages. We need to update the weather forecast in real time. The XMLHTTP component is used to capture the specified part of a webpage.
Html source code to be split
The captured html source code in this example is as follows:
Tuesday, August 24, 2004; daytime: Cloudy and sometimes cloudy with 3-4 South winds; nighttime: 3-4 South winds; temperature: The highest 29 ℃, the lowest 19 ℃
In the program
Search with the keyword August 24, 2004
Speed
The captured content is changed to "Tuesday, August 24, 2004; daytime: Cloudy and sometimes cloudy with 3-4 levels; nighttime: 3-4 levels of Qingnan wind; temperature: The highest 29 ℃, the lowest 19 ℃"
It's clean. Record it.
<%
On Error Resume Next
Server. ScriptTimeOut = 9999999
Function getHTTPPage (Path)
T = GetBody (Path)
GetHTTPPage = BytesToBstr (t, "GB2312 ")
End function
Function GetBody (url)
On error resume next
Set Retrieval = CreateObject ("Microsoft. XMLHTTP ")
With Retrieval
. Open "Get", url, False ,"",""
. Send
GetBody =. ResponseBody
End
Set Retrieval = Nothing
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
Function Newstring (wstr, strng)
Newstring = Instr (lcase (wstr), lcase (strng ))
If Newstring <= 0 then Newstring = Len (wstr)
End Function
%>