get_info_from_baiduzhidao_via_xmlhttp_and_adodb

<HTML> 
<html> 
<head> 
<META http-equiv="Content-Type" content="text/html; charset=gbk"> 
<title>test</title> 
<SCRIPT LANGUAGE="JavaScript"> 
<!-- 
window.onerror = function (err) { 
return false; 
}; 

//--> 
</SCRIPT> 
<script language="vbscript"> 
<!-- 

'獲取地址 
dim sUrl 

sUrl="http://zhidao.baidu.com/" 
Function streamtochar(StrStream) 
set stream=CreateObject("ADODB.Stream") 
stream.type=1 
stream.Mode=3 
stream.Open 
stream.Write Strstream 
stream.Position= 0 
stream.Type= 2 
stream.Charset="gbk" 
streamtochar= stream.ReadText 
stream.Close 
set stream=nothing 
End Function 

'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 

'函數,獲得內容 
function getContentByUrl(url) 

'創建對象 
set oXmlHttp = CreateObject("MSXML2.XMLHTTP") 

oXmlHttp.open "GET",url,false 

oXmlHttp.send 

getContentByUrl = streamtochar(oXmlHttp.responseBody) 

set oXmlHttp=nothing 
end function 


'函數,得到網站內容 
function getRealContent(url) 
sContent = getContentByUrl(url) 


getRealContent=sContent 
end function 


'--> 
</script> 
</head> 
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> 
<SCRIPT LANGUAGE=vbscript> 
<!-- 
str=getRealContent(sUrl) 
'document.write "<xmp>"&str &"</xmp>" 
'document.write str 
document.write "<META http-equiv=""Content-Type"" content=""text/html; charset=gbk"">"&str 

'--> 
</SCRIPT> 
</BODY> 
</HTML>

<!-- regedit
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\ActiveX Compatibility\{00000566-0000-0010-8000-00AA006D2EA4}]
"Compatibility Flags"=dword:00000000 -->
本站公眾號
   歡迎關注本站公眾號,獲取更多信息