The XMLHTTP component is used to capture the specified part of a webpage.

Source: Internet
Author: User

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
%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.