http://www.pythonchallenge.com/pc/def/linkedlist.php
网页的title是follow the chain
网页的注释中有提示, 需要修改nothing后面的数字少于400次
每修改一次都会在页面中显示下一次的数字, 重复操作即可
代码如下
import re
import urllib.request
front_url = "http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing="
num = "12345"
for i in range(1, 400):
url = front_url + num
page = urllib.request.urlopen(url)
text_bytes = page.read()
page.close()
text = text_bytes.decode("utf8")
result = re.findall(r"nothing is ([0-9]*)", text)
if result == []:
num = str(int(num) // 2)
print(i, num, text)
else:
num = ''.join(result)
print(i, num)
中间有一次会提示将数字除以2
最后结果为66831
页面为peak.html
输入地址栏即可进入下一关