这篇文章给大家介绍使用asp实现qq在线查询功能,涉及到的知识点有xmlhttp读取腾讯网站相应的html代码获取qq头像。对qq在线查询感兴趣的朋友可以参考下本篇文章
本文给大家分享的qq在线查询功能代码非常简单,具体内容如下:
这段程序的方法是利用XMLHTTP来读取腾讯网站的相应HTML代码获取QQ的头像,根据这个想法,我们还可以抓取很多其他网站的信息,如天气预报、新闻等等。
- <scriptlanguage=JavaScript>
- <!--
- functiongetFaceImg(QQcode)
- {
- varRe=newRegExp(^[1-9]{1}/d+$,g);
- if(!QQcode !Re.test(QQcode))return;
- varURL=http://search.tencent.com/cgi-bin/friend/oicq_find?oicq_no=+QQcode;
- varhttp=newActiveXObject(Microsoft.XMLHTTP);
- http.open(GET,URL,false,,);
- http.setRequestHeader(CONTENT-TYPE,text/html;Charset=gb2312);
- http.send();
- if(http.status!=200)return;
- varwebStr=http.responseText;
- Re=newRegExp((http://img.tencent.com/face/[^]+),ig);
- if(Re.test(webStr))
- return<ahref=http://search.tencent.com/cgi-bin/friend/user_show_info?ln=+QQcode+target=_blanktitle=QQ:+QQcode+><imgsrc=+RegExp.$1+width=16height=16border=0></a>;
- http=null;
- }
- document.write(我的QQ状态:+getFaceImg(44723461));
- //-->
- </script>
以上就是本文的全部所述,希望大家喜欢。