How to check QQ online status using Python

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.