Python Challenge Level4 は、とあるURLから次のURLをもらってどんどんアクセスしていくというものでした。
Webページには、
and the next nothing is 5868
というような文字列がでてくるので、この数値をURLのnothing=のところに格納します。
僕はこんな感じでスクリプトを書きました。
url = 'http colon slash slash www.pythonchallenge.com/pc/def/linkedlist.php?nothing=' next_number = '92512' for i in range(300): f = urllib.urlopen(url + next_number) content = f.read() print i, content next_number = (content.split(' '))[5]
ちなみに、このままでは次のレベルには行けず、途中ででてくるメッセージを読んでもう一捻りが必要です。