不知道大家對MSXML2.XMLHTTP是不是很熟悉,不過它的功能可以說是達到了極點.你可以通過它把別人的網站都"搬回來",呵呵,吹牛啦!! 今天我就用它從騰訊網站獲取一個QQ號碼的頭像,在線情況(人家隱身了我也沒辦法).當然大家也可以獲取QQ的昵稱,所在地等.具體實現方法如下: 先建立兩個函數,用來處理一個URL <% function getHTTPPage(url) dim http set http=createobject("MSXML2.XMLHTTP") Http.open "GET",url,false Http.send() if Http.readystate<>4 then exit function end if getHTTPPage=bytes2BSTR(Http.responseBody) set http=nothing if err.number<>0 then err.Clear end function '''''''以下處理字符 Function bytes2BSTR(vIn) dim strReturn dim i,ThisCharCode,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 End Function %> 這兩個函數你可以收藏起來,用處大得不得了. 大家可以先看看這個地址http://friend.qq.com/cgi-bin/friend/oicq_find?oicq_no=5292816 (QQ是本人的,我每天都很忙,請大家自覺,呵呵,討論問題非常歡迎) 以下我們就通過騰訊的好友查找來獲取信息, <% function qqhead(qq) url="http://friend.qq.com/cgi-bin/friend/oicq_find?oicq_no="&qq content=getHTTPPage(url) if len(content)>6360 then '如果QQ無效,做一些處理,避免錯誤發生. content=replace(mid(content,instr(content,"http://img.tencent.com"),38),"""","") qqhead="<a target='_blank'><img src='"&content&"' title='QQ:"&qq&"' border='0'></a>" else qqhead="" end if end function 'OK了,大功告成了.現在大家只要調用就行了. response.write qqhead(5292816) 如果QQ頭像是彩色的,說明好友在線,灰的就是不在線. %>
|