このプログラムの方法は、XMLHTTPを使用して、対応するTencent WebサイトのHTMLコードを読んでQQアバターを取得することです。このアイデアによれば、天気予報、ニュースなど、他のWebサイトから多くの情報をクロールすることもできます。
<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+" "ターゲット= _blanktitle =" qq: "+qqcode+" ">"> <imgsrc = ""+regexp。
http = null;
}
document.write( "my qq status:"+getfaceimg( "44723461"));
//->
</script>