迷题入口:http://www.pythonchallenge.com/pc/def/linkedlist.php
主要是不断变化的nothing,所以要用re和urllib
#
-*- coding: utf-8 -*-
__author__ = " hujinpu "
import urllib, re
content = urllib.urlopen( ' http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=12345 ' ).read()
pattern = re.compile(r ' nothing is (d+) ' )
newNothing = pattern.search(content).group( 1 )
while True:
content = urllib.urlopen( ' http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing= ' + newNothing).read()
try :
url = pattern.search(content).group( 1 )
except :
break
else :
newNothing = url
print newNothing
__author__ = " hujinpu "
import urllib, re
content = urllib.urlopen( ' http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=12345 ' ).read()
pattern = re.compile(r ' nothing is (d+) ' )
newNothing = pattern.search(content).group( 1 )
while True:
content = urllib.urlopen( ' http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing= ' + newNothing).read()
try :
url = pattern.search(content).group( 1 )
except :
break
else :
newNothing = url
print newNothing
中间还有小差曲,呵呵,就是发现不了pattern匹配,还有一次对2的除法,最后答案是peak.html