Size: 3970
Comment:
|
Size: 3969
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 107: | Line 107: |
)[2:10]\.replace('-','') +'.html' | )[2:10].replace('-','') +'.html' |
我就是那个很不起眼的Feather
此页保留~哈哈~
Mail: [email protected]
BLOG: http://blog.sohu.com/members/andelf/
BLOG: http://blog.sina.com.cn/u/1145264221
BLOG: http://spaces.msn.com/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
1 from urllib import urlopen
2 from datetime import datetime,timedelta
3 # a possible url:http://antwrp.gsfc.nasa.gov/apod/ap050825.html
4 urlprefix = """http://antwrp.gsfc.nasa.gov/apod/"""
5
6 # key code:
7 #"""<a href="image/0508/MWart_spitzer_f50.jpg"> ---full pic
8 #<IMG SRC="image/0508/MWart_spitzer_c42.jpg" ---mini pic
9 #alt="See Explanation. Clicking on the picture will download
10 #the highest resolution version available."></a>"""
11
12
13
14 def mini(code):
15 reswrtm.append(urlprefix+code[10:][:-1]+'\n')
16
17 def full(code):
18 reswrtf.append(urlprefix+code[9:][:-2]+'\n')
19
20 def getcode(url):
21 try:
22 f = urlopen(url).readlines()
23 for i in f:
24 if i.startswith('<a href="image'):
25 a = i
26 elif i.startswith('<IMG SRC="image/0'):
27 b = i
28 return (a.replace('\n',''),b.replace('\n',''))
29 except:
30 raise SystemExit
31
32 def makeurl(day):
33 start = datetime.now()
34 a = []
35 b = 1
36 #while b== day:
37 # a.append(urlprefix + 'ap' + \
38 # str(start - timedelta(b))[2:10].replace('-','') + \
39 # '.html')
40 a = [urlprefix + 'ap' + str(start -\
41 timedelta(i+1)\
42 )[2:10].replace('-','') +'.html'
43 for i in range(day)]
44 return a
45 reswrtm = []
46 reswrtf = []
47 if __name__== '__main__':
48 day = int(raw_input('How many days before?(numbers)'))
49 urllist = makeurl(day)[:]
50 for i in urllist:
51 a,b = getcode(i)
52 full(a)
53 mini(b)
54 resfile = file('full.txt','w')
55 resfile.writelines(reswrtf)
56 resfile.close()
57 resfile = file('mini.txt','w')
58 resfile.writelines(reswrtm)
59 resfile.close()
60 print """All pic's urls have been created!!
61 You can find them in the file mini.txt & full.txt!!"""
62 raw_input('Press Enter to exit!\n>>')
["个人网页类"]