<script>
x = new ActiveXObject("microsoft.XMLHTTP")
x.open("GET","http://info.china.alibaba.com/news/detail/v5-d5714299.html",false)
x.send()
alert(x.responseText)
</script>
x = new ActiveXObject("microsoft.XMLHTTP")
x.open("GET","http://info.china.alibaba.com/news/detail/v5-d5714299.html",false)
x.send()
alert(x.responseText)
</script>
x = new ActiveXObject("microsoft.XMLHTTP")
x.open("GET","http://www.52sdn.com/artid/33/33709.html",false)
x.send()
alert(x.responseText)
</script>也是乱码? 对一些大的网站 规范的没有乱码 一些普通的大家自己写的网站10有8,9是乱码
该怎么解决?
我个人是在服务端使用xmlhttp来抓取网页,用vb把乱码解码。
给你个vb函数
Function bytes2BSTR(vIn)
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
End Function