用js实现QQ在线查询功能
(编辑:jimmy 日期: 2024/12/28 浏览:3 次 )
这段程序的方法是利用XMLHTTP来读取腾讯网站的相应HTML代码获取QQ的头像,根据这个想法,我们还可以抓取很多其他网站的信息,如天气预报、新闻等等。
<script language="JavaScript">
<!--
function getFaceImg(QQcode)
{
var Re=new RegExp("^[1-9]{1}\d+$","g");
if (!QQcode !Re.test(QQcode)) return;
var URL="http://search.tencent.com/cgi-bin/friend/oicq_find?oicq_no="+QQcode;
var http=new ActiveXObject("Microsoft.XMLHTTP");
http.open("GET",URL,false,"","");
http.setRequestHeader("CONTENT-TYPE","text/html; Charset=gb2312");
http.send();
if (http.status!=200) return;
var webStr=http.responseText;
Re=new RegExp(""(http://img.tencent.com/face/[^"]+)"","ig");
if (Re.test(webStr))
return "<a href="http://search.tencent.com/cgi-bin/friend/user_show_info?ln="+QQcode+"" target=_blank title="QQ:"+QQcode+""><img src="/UploadFiles/2021-04-02/">
http=null;
}
document.write("我的QQ状态:"+getFaceImg("44723461"));
//-->
</script>
<script language="JavaScript">
<!--
function getFaceImg(QQcode)
{
var Re=new RegExp("^[1-9]{1}\d+$","g");
if (!QQcode !Re.test(QQcode)) return;
var URL="http://search.tencent.com/cgi-bin/friend/oicq_find?oicq_no="+QQcode;
var http=new ActiveXObject("Microsoft.XMLHTTP");
http.open("GET",URL,false,"","");
http.setRequestHeader("CONTENT-TYPE","text/html; Charset=gb2312");
http.send();
if (http.status!=200) return;
var webStr=http.responseText;
Re=new RegExp(""(http://img.tencent.com/face/[^"]+)"","ig");
if (Re.test(webStr))
return "<a href="http://search.tencent.com/cgi-bin/friend/user_show_info?ln="+QQcode+"" target=_blank title="QQ:"+QQcode+""><img src="/UploadFiles/2021-04-02/">
http=null;
}
document.write("我的QQ状态:"+getFaceImg("44723461"));
//-->
</script>
下一篇:asp遍历站点所有文件夹的代码