不知道大家對(duì)MSXML2.XMLHTTP是不是很熟悉,不過(guò)它的功能可以說(shuō)是達(dá)到了極點(diǎn).你可以通過(guò)它把別人的網(wǎng)站都"搬回來(lái)",呵呵,吹牛啦!! 今天我就用它從騰訊網(wǎng)站獲取一個(gè)QQ號(hào)碼的頭像,在線(xiàn)情況(人家隱身了我也沒(méi)辦法).當(dāng)然大家也可以獲取QQ的昵稱(chēng),所在地等.具體實(shí)現(xiàn)方法如下: 先建立兩個(gè)函數(shù),用來(lái)處理一個(gè)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 %> 這兩個(gè)函數(shù)你可以收藏起來(lái),用處大得不得了. 大家可以先看看這個(gè)地址http://friend.qq.com/cgi-bin/friend/oicq_find?oicq_no=5292816 (QQ是本人的,我每天都很忙,請(qǐng)大家自覺(jué),呵呵,討論問(wèn)題非常歡迎) 以下我們就通過(guò)騰訊的好友查找來(lái)獲取信息, <% 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無(wú)效,做一些處理,避免錯(cuò)誤發(fā)生. 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了,大功告成了.現(xiàn)在大家只要調(diào)用就行了. response.write qqhead(5292816) 如果QQ頭像是彩色的,說(shuō)明好友在線(xiàn),灰的就是不在線(xiàn). %>
|