不知道大家对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 href='http://friend.qq.com/cgi-bin/friend/user_show_info?ln="&qq&"' target='_blank'><img src='"&content&"' title='QQ:"&qq&"' border='0'></a>" else qqhead="" end if end function 'OK了,大功告成了.现在大家只要调用就行了. response.write qqhead(5292816) 如果QQ头像是彩色的,说明好友在线,灰的就是不在线. %> 大家可以到http://www.okwest.net/books看看效果.呵呵.
推荐阅读
强悍无比的WEB开发好助手FireBug(Firefox Plugin)
下载:firebug1.0-beta.zip怎么说呢,强就一个字啦~NND,上面这个图是我开到了 Ispect 状态,鼠标移动时截下来的。这比看源文件然后再搜索可是方便的太多了,这个世界是怎么了,还有这样的雷峰存在,真是太BT了~>>>详细阅读
本文标题:通过MSXML2自动获取QQ个人头像及在线情况(给初学者)
地址:http://www.17bianji.com/kaifa2/JS/31050.html
1/2 1