How to check QQ online status using Python
This article describes how to use Python to check the online status of QQ. It is very simple and practical to use Python to detect the online status of QQ through a third-party platform. For more information, see
This article describes how to check the online status of QQ using Python. Share it with you for your reference. The specific implementation method is as follows:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
Import time, datetime Import urllib2 Def chk_qq (qqnum ): Chkurl = 'HTTP: // wpa.paipai.com/pa? P = 1: '+ 'qqnum' +': 17' A = urllib2.urlopen (chkurl) Length = a. headers. get ("content-length ") A. close () Print datetime. datetime. now () Print length If length = '20140901 ': Return 'online' Elif length = '000000 ': Return 'offline' Else: Return 'unknown Status! ' Def writestate (statenow ): F = open (str (qq), 'A ') M = str (datetime. datetime. now () + "= state =" + statenow + "\ n \ r" F. write (m) F. close () Qq = 1, 847893543 # State = 1 If _ name __= = '_ main __': While 1: Stat = chk_qq (qq) Writestate (stat) Time. sleep (6000) # test once every 5 minutes Print 'qq' + 'is '+ stat |
I hope this article will help you with Python programming.