下一关。。。
一张图片,于是就点击了一下。
跳转到了
http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=12345
显示的是:
and the next nothing is 44827
下一个。。。
and the next nothing is 45439
再来一个。。
Your hands are getting tired and the next nothing is 94485。。。
一直循环下去了。。。肯定是打开的方式不对。。
回到原网页,F12
<!-- urllib may help. DON'T TRY ALL NOTHINGS, since it will never end. 400 times is more than enough. -->
额。回去上课,回来发代码。
这个有点坑爹。代码就直接发了。原理就是获取下一个链接的 nothing 然后用python 帮你自动进入下一个网页。大量循环。
#-*- coding:utf-8 -*- #代码版本均为python 3.5.1 #Level 4 import urllib.request import re def next_page(p): text = urllib.request.urlopen('http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=%s' % p).read().decode('utf-8') m = re.search('and the next nothing is ([0-9]+)', text) if not m: print (text) return m.group(1) p = 12345 for i in range(1,400): print (" 第%s次运行" % i,end="") p = next_page(p) print (p)
所以可以得到第5关的链接。
http://www.pythonchallenge.com/pc/def/peak.html
目前对第5关一脸懵bi。。。
晚上解