Crawl web pages. Occasionally, it is necessary to achieve real updated weather forecast. The XMLHTTP component is used to capture the specified part of the web page. In fact, many thief programs need to split the html source code to be more useful.
The captured html source code in this example is as follows
<p align=left>Tuesday, August 24, 2004; daytime: sunny and sometimes cloudy, Yunnan wind level 3-4; night: sunny south wind level 3-4; temperature: maximum 29℃ and minimum 19℃ </p>
The program is from
Use August 24, 2004 as the keyword search until</p>end
The captured content becomes Tuesday, August 24, 2004; daytime: sunny and sometimes cloudy, Yunnan wind level 3-4; night: sunny south wind level 3-4; temperature: maximum 29℃, minimum 19℃
It's clean. Record it.
Copy the code code as follows:
<%
On Error Resume Next
Server.ScriptTimeOut=9999999
Function getHTTPage(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 With
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
%>
<html>
<BODY bgColor=#ffffff leftMargin=0 topMargin=0 MARGINHEIGHT=0 MARGINWIDTH=0>
<!-- Start-->
<%
Dim wstr,str,url,start,over,dtime
dtime=Year(Date)&Year&Month(Date)&Month&Day(Date)&Day
url=http://www.vevb.com/
wstr=getHTTPage(url)
start=Newstring(wstr,dtime)
over=Newstring(wstr,</p>)
body=mid(wstr,start,over-start)
response.write <MARQUEE onmouseover=this.stop(); onmouseout=this.start();>&body&</marquee>
%>
<!--End-->
</body></html>