Write-up

[Python Challenge] level 4

ch4rli3kop 2019. 4. 13. 22:01
반응형

python challenge 4

urllib를 사용한다.

#!/usr/bin/python3

import urllib.request
'''
nothing = '12345'
while True:
  res = urllib.request.urlopen('http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=%s'%nothing)
  data = res.read().decode('utf-8')
  if 'and the next nothing is' not in data:
      break
  nothing = data.split(' ')[-1]
  print(data)

print('final : %s'%data)
'''
nothing = '8022'
while True:
       res = urllib.request.urlopen('http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=%s'%nothing)
       data = res.read().decode('utf-8')
       if 'and the next nothing is' not in data:
           break
       nothing = data.split(' ')[-1]
       print(data)

print('final : %s'%data)

중간에 함정이 두 개 숨겨져 있다. 2로 나눈 값을 사용하라는 경우와 숫자를 두 개주는 경우이다. 적당히 회피하도록 한다.

and the next nothing is 75635
and the next nothing is 52899
and the next nothing is 66831
final : peak.html

next : http://www.pythonchallenge.com/pc/def/peak.html solution : http://www.pythonchallenge.com/pcc/def/peak.html

반응형

'Write-up' 카테고리의 다른 글

[Python Challenge] level 6  (0) 2019.04.13
[Python Challenge] level 5  (0) 2019.04.13
[Python Challenge] level 3  (0) 2019.04.13
[Python Challenge] level 2  (0) 2019.04.13
[Python Challenge] level 1  (0) 2019.04.13