ASP如何获取远程HTML代码并存入变量!在线等!!!!!

来源:百度知道 编辑:UC知道 时间:2024/06/24 09:08:04
如题:像采集功能一样,获得远程HTML网页的源代码,并存入变量,而且显示的不能为乱码。我对XMLHTTP是菜鸟,请大虾请教,谢谢!

AJAX

<%
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
url = "http://www.baidu.com"
str = gethttpp