ASP获取QQ是否在线—绝对能用【经典】

ASP 1517 0 2013-02-16

ASP获取QQ是否在线—绝对能用【经典】
ASP获取QQ是否在线:

以前用来验证QQ是否在线的ASP代码,因为腾迅改版而不能用了,下面的是最新的保证可以用的代码,是个最基础的代码,具体应用的时候请自己更改。

<%
Function asp_isnull(str)
 if len(str)=0 or isnull(str) or str="" then
  asp_isnull=true
 else
  asp_isnull=false
 end if
end Function

'转换编码
Function BytesToBstr(Body, Cset)
   Dim Objstream
   Set Objstream = server.CreateObject("adodb.stream")
   Objstream.Type = 1
   Objstream.Mode = 3
   Objstream.Open
   Objstream.Write Body
   Objstream.Position = 0
   Objstream.Type = 2
   Objstream.Charset = Cset
   BytesToBstr = Objstream.ReadText
   Objstream.Close
   Set Objstream = Nothing
End Function

'获取网页源码
Function GetHttpPage(HttpUrl,CharsetCode)
 If IsNull(HttpUrl) = True Or Len(HttpUrl) < 18 Or HttpUrl = "Error" Then
   GetHttpPage = "Error"
   Exit Function
 End If
 Dim Http
 Set Http = server.CreateObject("MSXML2.ServerXMLHTTP")
 Http.Open "GET", HttpUrl, False
 on error resume next
 Http.Send
 If Http.Readystate <> 4 Then
 If Http.Status<>200 then
   Set Http = Nothing
   GetHttpPage = "Error"
   Exit Function
 End If
 End If
 GetHttpPage = BytesToBstr(Http.ResponseBody, CharsetCode)
 Set Http = Nothing
 If Err.Number <> 0 Then
   Err.Clear
 End If
End Function

dim qq
qq=request("qq")
if asp_isnull(qq) then
   response.write "请输qq号"
    response.end()
else
  dim qqstate
  qqstate=GetHttpPage("http://webpresence.qq.com/getonline?Type=1&"+qq&":","GB2312")
  qqstate=mid(qqstate,instr(qqstate,"=")+1,1)
  if qqstate="1" then 
     response.write "在线"
  else
    resposne.write "不在线"
  end if

end if
%>

上一篇:ASP判断来访者从哪个搜索引擎访问

下一篇:ASP实现解压缩的代码

讨论数量:0

请先登录再发表讨论。 2024-05-03

天涯网魂
3 杠 5 星
TA 的文章
TA 的随言
TA 的资源链