不知道大家对msxml2.xmlhttp是不是很熟悉,不过它的功能可以说是达到了极点.你可以通过它把别人的网站都搬回来,呵呵,吹牛啦!!
今天我就用它从腾讯网站获取一个qq号码的头像,在线情况(人家隐身了我也没办法).当然大家也可以获取qq的昵称,所在地等.具体实现方法如下:
先建立两个函数,用来处理一个url
复制代码 代码如下:
function gethttppage(url)
dim http
set http=createobject(msxml2.xmlhttp)
http.open get,url,false
http.send()
if http.readystate4 then
exit function
end if
gethttppage=bytes2bstr(http.responsebody)
set http=nothing
if err.number0 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 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=
else
qqhead=
end if
end function
'ok了,大功告成了.现在大家只要调用就行了.
response.write qqhead(5292816)
如果qq头像是彩色的,说明好友在线,灰的就是不在线.
%>
大家可以到http://www.okwest.net/books看看效果.呵呵.
