日期:2010-02-01  浏览次数:20816 次

远程抓取采集最常用的一个函数,自己举一反三吧

可以用远程获取XML数据,或HTML文件数据.通常还应用于通过HTTP获取index.asp动态主页来生成静态首页等用途...

爱易学习网www.aiyiweb.com还有更多教程,欢迎检索学习.

<%
function gethttppage(url)
dim adxmlhttp
set adxmlhttp = server.createobject("microsoft.xmlhttp")
adxmlhttp.open "get",url,false
adxmlhttp.send()
if adxmlhttp.readystate <> 4 then exit function
gethttppage = bytes2bstr(adxmlhttp.responsebody)
set adxmlhttp = nothing
End function

function bytes2bstr(vin)
dim bytesstream,stringreturn
set bytesstream = server.CreateObject("adodb.stream")
bytesstream.type = 2
bytesstream.open
bytesstream.writeText vin
bytesstream.position = 0
bytesstream.charset = "gb2312"
bytesstream.position = 2
stringreturn = bytesstream.readtext
bytesstream.close
set bytesstream = nothing
bytes2bstr = stringreturn
end function
%>