1 <% 2 On Error Resume Next 3 Server.Scripttimeout=9999999 4 Function Gethttppage(Path) 5 T = Getbody(Path) 6 Gethttppage=Bytestobstr(T,"Gb2312") 7 End Function 8 9 ' 首先,進行小偷程序的一些初始化設置,以上代碼的作用分別是忽略掉所有非致命性錯誤,把小偷程序的運行超時時間設置得很長(這樣不會出現運行超時的錯誤),轉換原來默認的utf-8編碼轉換成gb2312編碼,否則直接用xmlhttp組件調用有中文字符的網頁得到的將是亂碼。 10 11 Function Getbody(Url) 12 On Error Resume Next 13 Set Retrieval = Createobject("Microsoft.Xmlhttp") 14 With Retrieval 15 .Open "Get", Url, False, "", "" 16 .Send 17 Getbody = .Responsebody 18 End With 19 Set Retrieval = Nothing 20 End Function 21 22 '然后調用xmlhttp組件創建一個對象并進行初始化設置。 23 24 Function Bytestobstr(Body,Cset) 25 Dim Objstream 26 Set Objstream = Server.Createobject("Adodb.Stream") 27 Objstream.Type = 1 28 Objstream.Mode =3 29 Objstream.Open 30 Objstream.Write Body 31 Objstream.Position = 0 32 Objstream.Type = 2 33 Objstream.Charset = Cset 34 Bytestobstr = Objstream.Readtext 35 Objstream.Close 36 Set Objstream = Nothing 37 End Function 38 39 Function Newstring(Wstr,Strng) 40 Newstring=Instr(Lcase(Wstr),Lcase(Strng)) 41 If Newstring<=0 Then Newstring=Len(Wstr) 42 End Function 43 44 '處理抓取回來的數據需要調用adodb.Stream組件并進行初始化設置。%>