使用python检测手机QQ在线状态的脚本代码
程序员文章站
2022-05-14 09:05:55
复制代码 代码如下:import time,datetime import urllib2 def chk_qq...
复制代码 代码如下:
import time,datetime
import urllib2
def chk_qq(qqnum):
chkurl = 'http://wpa.qq.com/pa?p=1:'+`qqnum`+':1'
a = urllib2.urlopen(chkurl)
length=a.headers.get("content-length")
a.close()
print datetime.datetime.now()
if length=='2329':
return 'online'
elif length=='2262':
return 'offline'
else:
return 'unknown status!'
qq = 12345678
stat = chk_qq(qq)
print `qq` + ' is ' + stat