pythonchallenge level 17
2010. 10. 27. 11:51
푼지는 조금 됐지만 올려둔다.. 근 1년 여 만에 하다보니 전에 했던걸 다 잊어서 꽤나 고생했다.
http://www.pythonchallenge.com/pc/return/balloons.html
import urllib, re, cookielib,urllib2,bz2,xmlrpclib def get_page(number, extract): while 1: i = 0 url = "http://www.pythonchallenge.com/pc/def/linkedlist.php?busynothing=%s" % number 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' proxy = xmlrpclib.ServerProxy('http://www.pythonchallenge.com/pc/phonebook.php') print 'method %s' % (proxy.system.listMethods()) print 'phone number %s' % str(proxy.phone(name)) url = "http://www.pythonchallenge.com/pc/stuff/violin.php" 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 |