代碼執行個體:用Asp編程實現QQ的線上情況查詢

來源:互聯網
上載者:User
編程|線上

這段程式的方法是利用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=""+RegExp.$1+"" width=16 height=16 border=0></a>";  

  http=null;  
  }  

  document.write("我的QQ狀態:"+getFaceImg("44723461"));  
  //-->  
  </script>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.