Python queries whether qq is online, and python queries qq online

Source: Internet
Author: User

Python queries whether qq is online, and python queries qq online

Use Web http://wpa.paipai.com/pa? P = 1: '+ qq +': n to determine whether qq is online. qq is the qq number to be queried, and n is the number 1-17. select any one, the program uses n = 17 with different online conditions. The Code is as follows:

# Encoding: utf-8import time, datetimeimport urllib2 "" the program to determine whether QQ is online, QQ in the stealth status is also offline, and the detection qq time status is recorded in the file "class CheckQQ: def _ init _ (self, qq =''): self. qq = qq self. state = ''def check_qq (self): check_url = 'HTTP: // wpa.paipai.com/pa? P = 1: '+ self. qq + ': 17' content = urllib2.urlopen (check_url) length = content. headers. get ('content-length') Content. close () print datetime. datetime. now () if length = '000000': self. state = 'online' print 'online' elif length = '000000': self. state = 'offline' print 'offline' else: self. state = 'other status' print 'other status' def write2txt (self): name = self. qq province '.txt '# file name and file format qq_file = open (name, 'A') data = str (datetime. datetime. now () + "= state =" + self. state + "\ n \ r" qq_file.write (data) qq_file.close () if _ name __= = '_ main __': qq = '000000' qq_obj = CheckQQ (qq) while 1: qq_obj.check_qq () qq_obj.write2txt () time. sleep (60)
The program saves the qq status to the txt file every 60 seconds for easy viewing. If you need to detect the qq login status of MM, you can use this method to test and add the reminder function, which is more user-friendly. Thank you for sharing your ideas online.


How to Write a calendar query program in python without referencing the module?

#! /Usr/bin/evn python

Def simpleCalendar ():
DaysOfMonth = daysOfMonths = daysOfYears = month = year = 0
Yearfun = lambda year: year % 400 = 0 or year % 4 = 0 and year % 100! = 0
Print "*" * 30, "calendar", "*" * 30
Year = input ("enter year :")
Leap = yearfun (year)
Month = input ('enter month :')
Assert month in range (1, 13), "month must in 1-12"
If month = 2:
DaysOfMonth = 29 if leap else 28
Else:
DaysOfMonth = 30 if month in [4, 6, 9, 11] else 31

For I in range (1, month ):
If I = 2:
DaysOfMonths + = 29 if leap else 28
Else:
DaysOfMonths + = 30 if I in [4, 6, 9, 11] else 31

For I in range (1900, year ):
DaysOfYears + = 366 if yearfun (I) else 365
DaysOfYears + = daysOfMonths
Weak = 1 + daysOfYears % 7
Print "Sun \ tMon \ tTue \ tWed \ tThu \ tFri \ tSat"
Print "\ t" * weak,
For I in range (1, daysOfMonth + 1 ):
Weak + = 1
If weak % 7! = 0:
Print I, '\ t ',
Else:
Print I, '\ n ',

If _ name __= = '_ main __':
SimpleCalendar ()

How can I query method in python?

Query with help
>>> Help (obj. method) # Generic query method Object Name obj. method name method

This example
>>> Help ("". method) # "" is an empty string, but it is already a string object.

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.