查看QQ是否在线
源码:
import os,time,datetime,string import urllib2 def chk_qq(qqnum): chkurl = 'http://wpa.qq.com/pa?p=1:'+`qqnum`+':1' #print(chkurl) a = urllib2.urlopen(chkurl) length=a.headers.get("content-length") a.close() #print length print datetime.datetime.now() if length=='2329': return 'on' elif length=='2262': return 'off' else: return 'Unknown Status!' while True: qq = raw_input("input the QQ num:") if ( qq != "q" ): qq = string.atoi(qq) stat = chk_qq(qq) print `qq` + ' is ' + stat + '\n' else: print "exit!!" exit(0)
原理是打开网站:http://wpa.qq.com/pa?p=1:qq号:1 根据该网页信息来查看的!