Differences between revisions 4 and 5
Revision 4 as of 2006-01-18 01:16:30
Size: 167
Editor: ZhangYunfeng
Comment:
Revision 5 as of 2006-02-01 03:10:47
Size: 1950
Editor: andelf
Comment:
Deletions are marked like this. Additions are marked like this.
Line 6: Line 6:
{{{#!python
from urllib import thishost,urlopen
from time import time
myip = thishost()
myname = 'l_PwPUE~IBo<'
mypass = 'k@?6SYhabQA4'
def login(ip,username,password):
    logurl = r'http://172.31.1.21/ClientProcess.jsp?MsgType=0&LocalIP='+\
             ip+r'&username='+username+r'&password='+password
    f = urlopen(logurl).read()
    for i in f.split('&'):
        if i.startswith('loginKey'):
            a = i.replace('loginKey=','')
        elif i.startswith('username='):
            b = i.replace('username=','')
    if a and b:
        return (a, b)
    else: raise RuntimeError
def logout(ip,cname,logkey):
    outurl = r'http://172.31.1.21/ClientProcess.jsp?MsgType=3&ISNNO=1021&LocalIP='+\
              ip+r'&UserName='+cname+r'&LoginKey='+logkey+'&isPNP=0&httpIP='+ip
    f = urlopen(outurl).read()
    if f.find('ipconfig=0')!= -1:
        return True
    else: return False
print '*********Network Client For SXBCTV*********'
print 'Program By Feather ([email protected])'
print 'Now login to the server....'
try:
    p = login(myip, myname, mypass)
except:
    print 'Login Error, Check Connection Please!'
if p:
    start = time()
    key = p[0]
    cname = p[1]
    print 'You are Login As %s ,The Key is %s' % (cname, key)
else :
    print 'Login Error, Check Connection Please!'
while True:
    cmd = raw_input("Type 'exit' While You Want To Disconnect: \n>>>")
    if cmd in ['exit', 'bye', 'quit', 'logoff', 'disconnect']:
        if logout(myip, cname, key):
            end = time()
            print 'Time Lasted(s):', end-start
            print "You've Disconnected from the Server!!"
            raise SystemExit
        else:
            print 'Error occured......'
            raise SystemExit
}}}

我就是那个很不起眼的Feather

此页保留~哈哈~ Mail: mailto:[email protected] BLOG: http://blog.sohu.com/members/andelf/


   1 from urllib import thishost,urlopen
   2 from time import time
   3 myip = thishost()
   4 myname = 'l_PwPUE~IBo<'
   5 mypass = 'k@?6SYhabQA4'
   6 def login(ip,username,password):
   7     logurl = r'http://172.31.1.21/ClientProcess.jsp?MsgType=0&LocalIP='+\
   8              ip+r'&username='+username+r'&password='+password
   9     f = urlopen(logurl).read()
  10     for i in f.split('&'):
  11         if i.startswith('loginKey'):
  12             a = i.replace('loginKey=','')
  13         elif i.startswith('username='):
  14             b = i.replace('username=','')
  15     if a and b:
  16         return (a, b)
  17     else: raise RuntimeError
  18 def logout(ip,cname,logkey):
  19     outurl = r'http://172.31.1.21/ClientProcess.jsp?MsgType=3&ISNNO=1021&LocalIP='+\
  20               ip+r'&UserName='+cname+r'&LoginKey='+logkey+'&isPNP=0&httpIP='+ip
  21     f = urlopen(outurl).read()
  22     if f.find('ipconfig=0')!= -1:
  23         return True
  24     else: return False
  25 print '*********Network Client For SXBCTV*********'
  26 print 'Program By Feather ([email protected])'
  27 print 'Now login to the server....'
  28 try:
  29     p = login(myip, myname, mypass)
  30 except:
  31     print 'Login Error, Check Connection Please!'
  32 if p:
  33     start = time()
  34     key = p[0]
  35     cname = p[1]
  36     print 'You are Login As %s ,The Key is %s' % (cname, key)
  37 else :
  38     print 'Login Error, Check Connection Please!'
  39 while True:
  40     cmd = raw_input("Type 'exit' While You Want To Disconnect: \n>>>")
  41     if cmd in ['exit', 'bye', 'quit', 'logoff', 'disconnect']:
  42         if logout(myip, cname, key):
  43             end = time()
  44             print 'Time Lasted(s):', end-start
  45             print "You've Disconnected from the Server!!" 
  46             raise SystemExit
  47         else:
  48             print 'Error occured......'
  49             raise SystemExit

["个人网页类"]

Feather (last edited 2009-12-25 07:09:48 by localhost)