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组件并进行初始化设置。%>