Differences between revisions 7 and 10 (spanning 3 versions)
Revision 7 as of 2006-02-17 09:15:37
Size: 3970
Editor: andelf
Comment:
Revision 10 as of 2008-06-26 07:54:30
Size: 215
Editor: andelf
Comment:
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:
此页保留~哈哈~ == 关于自己 ==
Line 6: Line 6:
BLOG: http://blog.sohu.com/members/andelf/
Line 10: Line 8:
BLOG: http://spaces.msn.com/andelf BLOG: http://andelf.spaces.msn.com
由于本人很懒....
所以....
Line 12: Line 12:

{{{#!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
}}}
----
{{{#!python
from urllib import urlopen
from datetime import datetime,timedelta
# a possible url:http://antwrp.gsfc.nasa.gov/apod/ap050825.html
urlprefix = """http://antwrp.gsfc.nasa.gov/apod/"""

# key code:
#"""<a href="image/0508/MWart_spitzer_f50.jpg"> ---full pic
#<IMG SRC="image/0508/MWart_spitzer_c42.jpg" ---mini pic
#alt="See Explanation. Clicking on the picture will download
#the highest resolution version available."></a>"""



def mini(code):
    reswrtm.append(urlprefix+code[10:][:-1]+'\n')

def full(code):
    reswrtf.append(urlprefix+code[9:][:-2]+'\n')

def getcode(url):
    try:
        f = urlopen(url).readlines()
        for i in f:
            if i.startswith('<a href="image'):
                a = i
            elif i.startswith('<IMG SRC="image/0'):
                b = i
        return (a.replace('\n',''),b.replace('\n',''))
    except:
        raise SystemExit

def makeurl(day):
    start = datetime.now()
    a = []
    b = 1
    #while b== day:
    # a.append(urlprefix + 'ap' + \
    # str(start - timedelta(b))[2:10].replace('-','') + \
    # '.html')
    a = [urlprefix + 'ap' + str(start -\
                                timedelta(i+1)\
                                )[2:10]\.replace('-','') +'.html'
         for i in range(day)]
    return a
reswrtm = []
reswrtf = []
if __name__== '__main__':
    day = int(raw_input('How many days before?(numbers)'))
    urllist = makeurl(day)[:]
    for i in urllist:
        a,b = getcode(i)
        full(a)
        mini(b)
    resfile = file('full.txt','w')
    resfile.writelines(reswrtf)
    resfile.close()
    resfile = file('mini.txt','w')
    resfile.writelines(reswrtm)
    resfile.close()
    print """All pic's urls have been created!!
    You can find them in the file mini.txt & full.txt!!"""
    raw_input('Press Enter to exit!\n>>')
}}}
["个人网页类"]

我就是那个很不起眼的Feather

关于自己

Mail: [email protected]

BLOG: http://blog.sina.com.cn/u/1145264221

BLOG: http://andelf.spaces.msn.com 由于本人很懒.... 所以....


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