参考:ASP四个小技巧,抓取网页:GetBody,字节转字符BytesToBstr,正则表达式测试方法,生成静态页
Function GetBody(weburl)
‘创建对象
Dim ObjXMLHTTP
Set ObjXMLHTTP=Server.CreateObject("MSXML2.serverXMLHTTP")
‘请求文件,以异步形式
ObjXMLHTTP.Open "GET",weburl,False
‘此信息必须在send前一个设置否则将出错"msxml3.dll error ‘80004005‘ Unspecified error"
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
‘如果下面的方法在调用时使用()则会出现以下错误,如果非要使用()则需要使用call来调用方法
‘参考:http://www.cnblogs.com/y0umer/archive/2010/08/05/3839405.html
“ Microsoft VBScript compilation error ‘800a0414‘Cannotuse parentheses when calling a Sub”
‘xmlhttp.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded")
ObjXMLHTTP.send
While ObjXMLHTTP.readyState <> 4
ObjXMLHTTP.waitForResponse 1000
Wend
‘得到结果
GetBody=ObjXMLHTTP.responseBody
‘释放对象
Set ObjXMLHTTP=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
时间: 2024-10-23 01:19:47