วิธีการของโปรแกรมนี้คือการใช้ XMLHTTP เพื่ออ่านรหัส HTML ที่เกี่ยวข้องของเว็บไซต์ Tencent เพื่อรับ Avatar QQ ตามแนวคิดนี้เรายังสามารถรวบรวมข้อมูลจำนวนมากจากเว็บไซต์อื่น ๆ เช่นการพยากรณ์อากาศข่าว ฯลฯ
<scriptLanguage = "JavaScript">
-
FunctionGetFaceimg (qqCode)
-
varre = newregexp ("^[1-9] {1}/d+$", "g");
if (! qqcode! re.test (qqcode)) ส่งคืน;
varurl = "http://search.tencent.com/cgi-bin/friend/oicq_find?oicq_no="+qqcode;
varhttp = newActivexObject ("microsoft.xmlhttp");
http.open ("get", url, false, "", "");
http.setRequestheader ("เนื้อหาประเภท", "ข้อความ/html; charset = gb2312");
http.send ();
if (http.status! = 200) return;
varwebStr = http.responsetext;
re = newregexp ("" (http://img.tencent.com/face/ [ater^ "]+)" "," ig ");
if (re.test (webstr))
return "<ahref =" http://search.tencent.com/cgi-bin/friend/user_show_info?ln= "+qqcode+" "target = _blanktitle =" qq: "+qqcode+" "> <imgsrc =" "
http = null;
-
document.write ("สถานะ QQ ของฉัน:"+getFaceimg ("44723461"));
-
</script>