Function getHTTPPage(url)
on error resume next
response.write i+1&url&"<br>"
'response.end
dim httpt
set httpt=Server.createobject("Microsoft.XMLHTTP")
Httpt.open "GET",url,false,"", ""
Httpt.send
if err.number<>0 then
Response.write err.description
'Response.End
end if
if Httpt.readystate<>4 then
exit function
end if
getHTTPPage=bytesToBSTR(Httpt.responseBody,"GB2312")
set httpt=nothing
if err.number<>0 then err.Clear
End function
我封装了以下两个函数,你试试:ReadData(url)有没有问题
'字符转换
Function bytes2BSTR(vIn)
On Error Resume Next
Dim strReturn,i,ThisCharCode,innerCode,Hight8,Low8,NextCharCode
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
If Err.Number <> 0 Then Err.Clear
End Function
'读取数据
Function ReadData(Url)
On Error Resume Next
Dim myXml
Set myXml = CreateObject("Microsoft.XMLHttp")
If Err.Number <> 0 Then Set myXml = CreateObject("Msxml2.XMLHTTP")
myXml.Open "Get", Url, False
'myXml.SetRequestHeader "Content-type", "text/html"
myXml.Send()
If myXml.ReadyState <> 4 Then
ReadData = "读取数据出错!"
Else
ReadData = bytes2BSTR(myXml.ResponseBody)
End If
Set myXml = Nothing
If Err.Number <> 0 Then Err.Clear
End Function