首先,题意需要明确,让我门尝试nothing的值,我们猜测这是一个变量
http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=abc
页面返回了:and the next nothing is 6711
接着我们尝试:http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=6711
页面返回了:and the next nothing is 2795
….
这就是一个循环
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import urllib, re, time uri = "http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=%s" nothing_rep = "and the next nothing is (\d+)" nothing = "18022" # You'll later be asked to change this # to "46059" and re-run the script. while True: try: print "start" source = urllib.urlopen(uri % nothing).read() print source nothing = re.search(nothing_rep, source).group(1) except: break print nothing |
第一次执行之后返回的结果是:
…
16044
start
Yes. Divide by two and keep going.
这个时候,我们要修改一下我们的程序,把参数设置为16044/2
然后继续
然后得到结果:
peak.html
Latest posts by Zhiming Zhang (see all)
- aws eks node 自动化扩展工具 Karpenter - 8月 10, 2022
- ReplicationController and ReplicaSet in Kubernetes - 12月 20, 2021
- public key fingerprint - 5月 27, 2021