python challenge 4
http://www.pythonchallenge.com/pc/def/linkedlist.php
点图片 进入 ==> http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=12345
点几下就明白要做什么了
中间要根据结果几次修正
01 import urllib2
02 import re
03 str = 'http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=%s'
04 num = 12345
05
06 while num:
07 cont = urllib2.urlopen(str % num).read()
08 result = re.compile('the next nothing is (\d+)').findall(cont)
09 print cont
10 if len(result) != 1:
11 print 'Finshed'
12 break
13 num = result[0]
最后一次:
10:11:35@~/script/py> python 4.py
and the next nothing is 33110
and the next nothing is 17675
and the next nothing is 8511
and the next nothing is 89456
and the next nothing is 43502
and the next nothing is 45605
and the next nothing is 12970
and the next nothing is 91060
and the next nothing is 27719
and the next nothing is 65667
peak.html
get:
http://www.pythonchallenge.com/pc/def/peak.html
点图片 进入 ==> http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=12345
点几下就明白要做什么了
中间要根据结果几次修正
01 import urllib2
02 import re
03 str = 'http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=%s'
04 num = 12345
05
06 while num:
07 cont = urllib2.urlopen(str % num).read()
08 result = re.compile('the next nothing is (\d+)').findall(cont)
09 print cont
10 if len(result) != 1:
11 print 'Finshed'
12 break
13 num = result[0]
最后一次:
10:11:35@~/script/py> python 4.py
and the next nothing is 33110
and the next nothing is 17675
and the next nothing is 8511
and the next nothing is 89456
and the next nothing is 43502
and the next nothing is 45605
and the next nothing is 12970
and the next nothing is 91060
and the next nothing is 27719
and the next nothing is 65667
peak.html
get:
http://www.pythonchallenge.com/pc/def/peak.html