pythonchallenge level 17
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | import urllib, re, cookielib,urllib2,bz2,xmlrpclib def get_page(number, extract): while 1 : i = 0 cj = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) f = opener. open (url) file = f.read() extract.append( list (cj)[ 0 ].value) text = re.findall( "next busynothing is \d+" , file ) if text: text_last = text[ 0 ] number_list = re.findall( "[0-9]+" ,text_last) number = '' while 1 : number + = number_list[i] i + = 1 if i = = len (number_list): break else : text = re.findall( "that" , file ) break num = 12345 txt = [] get_page(num,txt) temp = urllib.unquote_plus(''.join(txt)) print bz2.BZ2Decompressor().decompress(temp) name = 'Leopold' print 'method %s' % (proxy.system.listMethods()) print 'phone number %s' % str (proxy.phone(name)) cj = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) f = opener. open (url) file = f.read() print file info = 'the flowers are on their way' req = urllib2.Request(url, headers = { 'cookie' : 'info=' + urllib.quote_plus(info)}) print urllib2.urlopen(req).read() |
http://www.pythonchallenge.com/pc/return/balloons.html
'War game > pythonchallenge' 카테고리의 다른 글
pythonchallenge level16 (0) | 2009.12.04 |
---|---|
pythonchallenge level 15 (0) | 2009.12.03 |
pythonchallenge level14 (0) | 2009.11.17 |
pythonchallenge level13 (0) | 2009.10.22 |
pythonchallenge level12 (0) | 2009.10.22 |
pythonchallenge level11 (0) | 2009.10.22 |
pythonchallenge level10 (0) | 2009.10.20 |
pythonchallenge level9 (0) | 2009.10.16 |
pythonchallenge level8 (0) | 2009.10.16 |
pythonchallenge level7 (0) | 2009.10.16 |