xml| Web page
XMLHTTP Crawl Web page, recently in the blog to see this article, so on the way posted to the blog,
Original url:http://www.cnblogs.com/hover/archive/2004/10/09/36212.aspx (Blog Park-flying. Net blog)
Crawl Web pages. I want to implement thorough update weather forecast. The XMLHTTP component is used to crawl the specified portion of the page.
Need to split HTML source code
In this example, the crawled HTML source code is as follows
<p align=left>2004 Year August 24 Tuesday; Daytime: Sunny Sometimes cloudy southerly 3-4 class; Night: Clear South wind 3-4; temperature: Up to 29 ℃ minimum 19℃</p>
And the program is from
Search by August 24, 2004 for keywords until the </p> knot speed
The contents of the capture became "August 24, 2004 Tuesday; Day: Sunny sometimes cloudy southerly 3-4 class; Night: Clear South wind 3-4; temperature: Max 29 ℃ minimum 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 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
%>
<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.qianhuaweb.com/"
Wstr=gethttppage (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>