欧美激情网,国产欧美亚洲高清,欧美屁股xxxxx,欧美群妇大交群,欧美人与物ⅴideos另类,区二区三区在线 | 欧洲

知識(shí)學(xué)堂
  • ·聯(lián)系電話:+86.023-75585550
  • ·聯(lián)系傳真:+86.023-75585550
  • ·24小時(shí)手機(jī):13896886023
  • ·QQ 咨 詢:361652718 513960520
當(dāng)前位置 > 首頁(yè) > 知識(shí)學(xué)堂 > 網(wǎng)站建設(shè)知識(shí)
asp 利用 xmlhttp 抓取網(wǎng)頁(yè)內(nèi)容
更新時(shí)間:2012-03-12 | 發(fā)布人:本站 | 點(diǎn)擊率:287
抓取網(wǎng)頁(yè)。偶要實(shí)現(xiàn)實(shí)實(shí)更新天氣預(yù)報(bào)。利用了XMLHTTP組件,抓取網(wǎng)頁(yè)的指定部分。
需要分件html源代碼
此例中的被抓取的html源代碼如下
<p align=left>2004年8月24日星期二;白天:晴有時(shí)多云南風(fēng)3—4級(jí);夜間:晴南風(fēng)3—4級(jí);氣溫:最高29℃最低19℃ </p>
而程序中是從
以2004年8月24日為關(guān)鍵字搜索,直到</p>結(jié)速
而抓取的內(nèi)容就變成了"2004年8月24日星期二;白天:晴有時(shí)多云南風(fēng)3—4級(jí);夜間:晴南風(fēng)3—4級(jí);氣溫:最高29℃最低19℃ "
干干凈凈的了。記錄一下。

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

<html>

<BODY bgColor=#ffffff leftMargin=0 topMargin=0 MARGINHEIGHT=0 MARGINWIDTH=0>
<!-- 開(kāi)始 -->   

<%
Dim wstr,str,url,start,over,dtime
dtime=Year(Date)&"年"&Month(Date)&"月"&Day(Date)&"日"
url="        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>"


%>
<!-- 結(jié)束 -->
</body></html>