The method of this program is to use XMLHTTP to read the corresponding HTML code of the Tencent website to obtain the QQ avatar. Based on this idea, we can also capture a lot of information from other websites, such as weather forecasts and news.
<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 +" \ "> </a> ";
Http = null;
}
Document. write ("my QQ status:" + getFaceImg ("44723461 "));
// -->
</Script>